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
1. Dependent resources are explicitly created and can be access later by reference.
306
-
2. Event sources are produced by the dependent resources, but needs to be explicitly registered in
307
-
this case by implementing
308
-
the [`EventSourceInitializer`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/EventSourceInitializer.java)
309
-
interface.
310
-
3. The input html is validated, and error message is set in case it is invalid.
311
-
4. Reconciliation of dependent resources is called explicitly, but here the workflow
312
-
customization is fully in the hand of the developer.
313
-
5. An `Ingress` is created but only in case `exposed` flag set to true on custom resource. Tries to
314
-
delete it if not.
315
-
6. Status is set in a different way, this is just an alternative way to show, that the actual state
316
-
can be read using the reference. This could be written in a same way as in the managed example.
Note also the Workflows feature makes it possible to also support this conditional creation use
323
-
case in managed dependent resources.
231
+
You can see a commented example of how to do
232
+
so [here](https://github.com/operator-framework/java-operator-sdk/blob/main/sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageStandaloneDependentsReconciler.java).
324
233
325
234
## Creating/Updating Kubernetes Resources
326
235
@@ -353,17 +262,17 @@ Since SSA is a complex feature, JOSDK implements a feature flag allowing users t
353
262
these implementations. See
354
263
in [ConfigurationService](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java#L332-L358).
355
264
356
-
It is, however, important to note that these implementations are default, generic
357
-
implementations that the framework can provide expected behavior out of the box. In many
358
-
situations, these will work just fine but it is also possible to provide matching algorithms
265
+
It is, however, important to note that these implementations are default, generic
266
+
implementations that the framework can provide expected behavior out of the box. In many
267
+
situations, these will work just fine but it is also possible to provide matching algorithms
359
268
optimized for specific use cases. This is easily done by simply overriding
360
-
the `match(...)`[method](https://github.com/java-operator-sdk/java-operator-sdk/blob/e16559fd41bbb8bef6ce9d1f47bffa212a941b09/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java#L156-L156).
269
+
the `match(...)`[method](https://github.com/java-operator-sdk/java-operator-sdk/blob/e16559fd41bbb8bef6ce9d1f47bffa212a941b09/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/KubernetesDependentResource.java#L156-L156).
361
270
362
-
It is also possible to bypass the matching logic altogether to simply rely on the server-side
271
+
It is also possible to bypass the matching logic altogether to simply rely on the server-side
363
272
apply mechanism if always sending potentially unchanged resources to the cluster is not an issue.
364
273
JOSDK's matching mechanism allows to spare some potentially useless calls to the Kubernetes API
365
-
server. To bypass the matching feature completely, simply override the `match` method to always
366
-
return `false`, thus telling JOSDK that the actual state never matches the desired one, making
274
+
server. To bypass the matching feature completely, simply override the `match` method to always
275
+
return `false`, thus telling JOSDK that the actual state never matches the desired one, making
367
276
it always update the resources using SSA.
368
277
369
278
WARNING: Older versions of Kubernetes before 1.25 would create an additional resource version for every SSA update
resource, since there could be multiple instances of that type which could possibly be used, each
303
+
associated with the same primary resource. In this situation, JOSDK automatically selects the appropriate secondary
304
+
resource matching the desired state associated with the primary resource. This makes sense because the desired
305
+
state computation already needs to be able to discriminate among multiple related secondary resources to tell JOSDK how
306
+
they should be reconciled.
307
+
308
+
There might be casees, though, where it might be problematic to call the `desired` method several times (for example, because it is costly to do so), it is always possible to override this automated discrimination using several means:
309
+
310
+
- Implement your own `getSecondaryResource` method on your `DependentResource` implementation from scratch.
311
+
- Override the `selectManagedSecondaryResource` method, if your `DependentResource` extends `AbstractDependentResource`.
312
+
This should be relatively simple to override this method to optimize the matching to your needs. You can see an
313
+
example of such an implementation in
314
+
the [`ExternalWithStateDependentResource`](https://github.com/operator-framework/java-operator-sdk/blob/6cd0f884a7c9b60c81bd2d52da54adbd64d6e118/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/externalstate/ExternalWithStateDependentResource.java#L43-L49)
315
+
class.
316
+
- Override the `managedSecondaryResourceID` method, if your `DependentResource` extends `KubernetesDependentResource`,
317
+
where it's very often possible to easily determine the `ResourceID` of the secondary resource. This would probably be
318
+
the easiest solution if you're working with Kubernetes resources.
319
+
320
+
### Sharing an Event Source Between Dependent Resources
407
321
408
322
Dependent resources usually also provide event sources. When dealing with multiple dependents of
409
323
the same type, one needs to decide whether these dependent resources should track the same
@@ -419,10 +333,10 @@ would look as follows:
419
333
useEventSourceWithName = "configMapSource")
420
334
```
421
335
422
-
A sample is provided as an integration test both
423
-
for [managed](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/MultipleManagedDependentSameTypeIT.java)
for [managed](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/MultipleManagedDependentNoDiscriminatorIT.java)
@@ -485,15 +399,18 @@ also be created, one per dependent resource.
485
399
See [integration test](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/ExternalStateBulkIT.java)
486
400
as a sample.
487
401
488
-
489
402
## GenericKubernetesResource based Dependent Resources
490
403
491
-
In rare circumstances resource handling where there is no class representation or just typeless handling might be needed.
For dependent resource this is supported by [GenericKubernetesDependentResource](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/GenericKubernetesDependentResource.java#L8-L8)
496
-
. See samples [here](https://github.com/java-operator-sdk/java-operator-sdk/tree/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/generickubernetesresource).
410
+
For dependent resource this is supported
411
+
by [GenericKubernetesDependentResource](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/dependent/kubernetes/GenericKubernetesDependentResource.java#L8-L8)
0 commit comments