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/access-resources.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ weight: 48
4
4
---
5
5
6
6
As described in [Event sources and related topics](eventing.md) event sources are the backbone
7
-
for caching resources and triggering the reconciliation for primary resources thar are related
7
+
for caching resources and triggering the reconciliation for primary resources that are related
8
8
to cached resources.
9
9
10
10
In Kubernetes world, the component that does this is called Informer. Without going into
@@ -23,25 +23,25 @@ The purpose of such wrapping is to add additional capabilities required for cont
23
23
(In general, Informers are not used only for implementing controllers).
24
24
25
25
Such capabilities are:
26
-
- maintaining and index to which primary are the secondary resources in informer cache are related to.
26
+
- maintaining an index to which primary resources the secondary resources in informer cache are related to.
27
27
- setting up multiple informers for the same type if needed. You need informer per namespace if the informer
28
28
is not watching the whole cluster.
29
29
- Dynamically adding/removing watched namespaces.
30
-
- Some others, what is out of the scope of this document.
30
+
- Some others, which are out of the scope of this document.
31
31
32
32
### Associating Secondary Resources to Primary Resource
33
33
34
-
The question is, how to trigger reconciliation of a primary resources (your custom resource),
34
+
The question is, how to trigger reconciliation of a primary resource (your custom resource),
35
35
when Informer receives a new resource.
36
36
For this purpose the framework uses [`SecondaryToPrimaryMapper`](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/SecondaryToPrimaryMapper.java)
37
37
that tells (usually) based on the resource which primary resource reconciliation to trigger.
38
38
The mapping is usually done based on the owner reference or annotation on the secondary resource.
39
39
(But not always, as we will see)
40
40
41
41
It is important to realize that if a resource triggers the reconciliation of a primary resource, that
42
-
resource naturally will be used during reconciliation. So the reconciler will need to access them.
43
-
Therefore, InformerEventSource maintains a revers index [PrimaryToSecondaryIndex](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/DefaultPrimaryToSecondaryIndex.java),
44
-
based on the result of the `SecondaryToPrimaryMapper`result.
42
+
resource naturally will be used during reconciliation. So the reconciler will need to access it.
43
+
Therefore, InformerEventSource maintains a reverse index [PrimaryToSecondaryIndex](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/DefaultPrimaryToSecondaryIndex.java),
44
+
based on the result of the `SecondaryToPrimaryMapper`.
45
45
46
46
## Unified API for Related Resources
47
47
@@ -56,7 +56,7 @@ That will list all the related resources of a certain type, based on the `Inform
56
56
Based on that index, it reads the resources from the Informers cache. Note that since all those steps work
57
57
on top of indexes, those operations are very fast, usually O(1).
58
58
59
-
We mostly talk about InformerEventSource, but this works in similar ways for generalized EventSources concept, since
59
+
We mostly talk about InformerEventSource, but this works in similar ways for the generalized EventSources concept, since
60
60
the [`EventSource`](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/EventSource.java#L93)
61
61
actually implements the `Set<R> getSecondaryResources(P primary);` method. That is just called from the context.
62
62
@@ -106,7 +106,7 @@ called and which usually have an owner reference pointing to the primary (and, t
106
106
cover `related` resources (which might or might not be managed by Kubernetes) that serve as input for reconciliations.
107
107
108
108
There are cases where the SDK needs more information than what is readily available, in particular when some of these
109
-
secondary resources do not have owner references or anything direct link to the primary resource they are associated
109
+
secondary resources do not have owner references or any direct link to the primary resource they are associated
110
110
with.
111
111
112
112
As an example we provide, consider a `Job` primary resource which can be assigned to run on a cluster, represented by a
0 commit comments