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/documentation/dependent-resources.md
+24-1Lines changed: 24 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -452,7 +452,7 @@ as a sample.
452
452
`getResource()` of the dependent resource or getting the resource from the `EventSource`
453
453
itself won't return the just updated resource, in the case where the associated event hasn't
454
454
been received from the Kubernetes API. The `KubernetesDependentResource` implementation,
455
-
however, addresses this issue so you don't have to worry about it by making sure that it or
455
+
however, addresses this issue, so you don't have to worry about it by making sure that it or
456
456
the related `InformerEventSource` always return the up-to-date resource.
457
457
458
458
2. Another feature of `KubernetesDependentResource` is to make sure that if a resource is created or
@@ -468,3 +468,26 @@ as a sample.
468
468
to select only the relevant events, see
469
469
in [related integration test](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework/src/test/java/io/javaoperatorsdk/operator/sample/orderedmanageddependent/ConfigMapDependentResource1.java)
470
470
.
471
+
472
+
## "Read-only" Dependent Resources vs. Event Source
473
+
474
+
Some secondary resources only exist as input for the reconciliation process and are never
475
+
updated *by a controller* (they might, and actually usually do, get updated by users interacting
476
+
with the resources directly, however). This might be the case, for example, of a `ConfigMap`that is
477
+
used to configure common characteristics of multiple resources in one convenient place.
478
+
479
+
In such situations, one might wonder whether it makes sense to create a dependent resource in
480
+
this case or simply use an `EventSource` so that the primary resource gets reconciled whenever a
481
+
user changes the resource. Typical dependent resources provide a desired state that the
482
+
reconciliation process attempts to match. In the case of so-called read-only dependents, though,
483
+
there is no such desired state because the operator / controller will never update the resource
484
+
itself, just react to external changes to it. An `EventSource` would achieve the same result.
485
+
486
+
Using a dependent resource for that purpose instead of a simple `EventSource`, however, provides
487
+
several benefits:
488
+
- dependents can be created declaratively, while an event source would need to be manually created
489
+
- if dependents are already used in a controller, it makes sense to unify the handling of all
490
+
secondary resources as dependents from a code organization perspective
491
+
- dependent resources can also interact with the workflow feature, thus allowing the read-only
492
+
resource to participate in conditions, in particular to decide whether or not the primary
493
+
resource needs/can be reconciled using reconcile pre-conditions
0 commit comments