You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content/en/docs/documentation/reconciler.md
+19-18Lines changed: 19 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -27,18 +27,21 @@ Once the reconciliation is done, the framework checks if:
27
27
In summary, the core of the SDK is implemented as an eventing system where events trigger
28
28
reconciliation requests.
29
29
30
-
## Implementing a [`Reconciler`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Reconciler.java) and/or [`Cleaner`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Cleaner.java)
30
+
## Implementing a Reconciler andCleaner interfaces
31
31
32
-
The lifecycle of a Kubernetes resource can be separated into two phases depending on weather the resource is already marked for deletion or not.
32
+
To implement a reconciler, you always have to implement the [`Reconciler`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Reconciler.java) interface.
33
+
34
+
The lifecycle of a Kubernetes resource can be separated into two phases depending on whether the resource has already been marked for deletion or not.
33
35
34
36
The framework out of the box supports this logic, it will always
35
37
call the `reconcile` method unless the custom resource is
36
-
[marked from deletion](https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/#how-finalizers-work)
37
-
. On the other, if the resource is marked from deletion and if the `Reconciler` implements the
38
-
`Cleaner` interface, only the `cleanup` method is called. By implementing the `Cleaner`
38
+
[marked from deletion](https://kubernetes.io/docs/concepts/overview/working-with-objects/finalizers/#how-finalizers-work).
39
+
40
+
On the other, if the resource is marked from deletion and if the `Reconciler` implements the
41
+
[`Cleaner`](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Cleaner.java) interface, only the `cleanup` method is called. By implementing the `Cleaner`
39
42
the framework will automatically handle (add/remove) the finalizers for you.
40
43
41
-
See[Finalizer support](#finalizer-support) for more details.
44
+
In short, if you need to provide explicit cleanup logic, you always want to use finalizers; for a more detailed explanation, see[Finalizer support](#finalizer-support) for more details.
42
45
43
46
### Using `UpdateControl` and `DeleteControl`
44
47
@@ -133,32 +136,30 @@ Kubernetes cluster (e.g. external resources), you might not need to use finalize
mechanism as much as possible by setting owner references for your secondary resources so that
136
-
the cluster can automatically deleted them for you whenever the associated primary resource is
139
+
the cluster can automatically delete them for you whenever the associated primary resource is
137
140
deleted. Note that setting owner references is the responsibility of the `Reconciler`
138
141
implementation, though [dependent resources](https://javaoperatorsdk.io/docs/dependent-resources)
139
142
make that process easier.
140
143
141
-
If you do need to clean such state, you need to use finalizers so that their
144
+
If you do need to clean such a state, you need to use finalizers so that their
142
145
presence will prevent the Kubernetes server from deleting the resource before your operator is
143
-
ready to allow it. This allows for clean up to still occur even if your operator was down when
144
-
the resources was "deleted" by a user.
146
+
ready to allow it. This allows for clean-up even if your operator was down when the resource was marked for deletion.
145
147
146
148
JOSDK makes cleaning resources in this fashion easier by taking care of managing finalizers
147
149
automatically for you when needed. The only thing you need to do is let the SDK know that your
148
-
operator is interested in cleaning state associated with your primary resources by having it
150
+
operator is interested in cleaning the state associated with your primary resources by having it
149
151
implement
150
152
the [`Cleaner<P>`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Cleaner.java)
151
153
interface. If your `Reconciler` doesn't implement the `Cleaner` interface, the SDK will consider
152
-
that you don't need to perform any clean-up when resources are deleted and will therefore not
153
-
activate finalizer support. In other words, finalizer support is added only if your `Reconciler`
154
-
implements the `Cleaner` interface.
154
+
that you don't need to perform any clean-up when resources are deleted and will, therefore, not activate finalizer support.
155
+
In other words, finalizer support is added only if your `Reconciler` implements the `Cleaner` interface.
155
156
156
-
Finalizers are automatically added by the framework as the first step, thus after a resource
157
-
is created, but before the first reconciliation. The finalizer is added via a separate
157
+
The framework automatically adds finalizers as the first step, thus after a resource
158
+
is created but before the first reconciliation. The finalizer is added via a separate
158
159
Kubernetes API call. As a result of this update, the finalizer will then be present on the
159
160
resource. The reconciliation can then proceed as normal.
160
161
161
-
The finalizer that is automatically added will be also removed after the `cleanup` is executed on
162
+
The automatically added finalizer will also be removed after the `cleanup` is executed on
162
163
the reconciler. This behavior is customizable as explained
163
164
[above](#using-updatecontrol-and-deletecontrol) when we addressed the use of
164
165
`DeleteControl`.
@@ -167,4 +168,4 @@ You can specify the name of the finalizer to use for your `Reconciler` using the
0 commit comments