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
+70-73Lines changed: 70 additions & 73 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,69 +3,67 @@ title: Accessing resources in caches
3
3
weight: 48
4
4
---
5
5
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 that are related
6
+
As described in [Event sources and related topics](eventing.md), event sources serve as the backbone
7
+
for caching resources and triggering reconciliation for primary resources that are related
8
8
to cached resources.
9
9
10
-
In Kubernetes world, the component that does this is called Informer. Without going into
11
-
the details (there are plenty of good documents online regarding informers), its responsibility
12
-
is to watch resources, cache them, and emit an event if the resource changed.
10
+
In the Kubernetes ecosystem, the component responsible for this is called an Informer. Without delving into
11
+
the details (there are plenty of excellent resources online about informers), its responsibility
12
+
is to watch resources, cache them, and emit events when resources change.
13
13
14
-
EventSource is a generalized concept of Informer to non-Kubernetes resources. Thus,
15
-
to cache external resources, and trigger reconciliation if those change.
14
+
EventSource is a generalized concept that extends the Informer pattern to non-Kubernetes resources,
15
+
allowing you to cache external resources and trigger reconciliation when those resources change.
16
16
17
17
## The InformerEventSource
18
18
19
-
The underlying informer implementation comes from the fabric8 client, called[DefaultSharedIndexInformer](https://github.com/fabric8io/kubernetes-client/blob/main/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/impl/DefaultSharedIndexInformer.java).
in Java Operator SDK wraps informers from fabric8 client.
22
-
The purpose of such wrapping is to add additional capabilities required for controllers.
23
-
(In general, Informers are not used only for implementing controllers).
19
+
The underlying informer implementation comes from the fabric8 client, specifically the[DefaultSharedIndexInformer](https://github.com/fabric8io/kubernetes-client/blob/main/kubernetes-client/src/main/java/io/fabric8/kubernetes/client/informers/impl/DefaultSharedIndexInformer.java).
in Java Operator SDK wraps the fabric8 client informers.
22
+
This wrapper adds additional capabilities specifically required for controllers
23
+
(note that informers have broader applications beyond just implementing controllers).
24
24
25
-
Such capabilities are:
26
-
- maintaining an index to which primary resources the secondary resources in informer cache are related to.
27
-
- setting up multiple informers for the same type if needed. You need informer per namespace if the informer
28
-
is not watching the whole cluster.
29
-
- Dynamically adding/removing watched namespaces.
30
-
- Some others, which are out of the scope of this document.
25
+
These additional capabilities include:
26
+
- Maintaining an index that maps secondary resources in the informer cache to their related primary resources
27
+
- Setting up multiple informers for the same resource type when needed (for example, you need one informer per namespace if the informer is not watching the entire cluster)
28
+
- Dynamically adding and removing watched namespaces
29
+
- Other capabilities that are beyond the scope of this document
31
30
32
31
### Associating Secondary Resources to Primary Resource
33
32
34
-
The question is, how to trigger reconciliation of a primary resource (your custom resource),
35
-
when Informer receives a new resource.
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
-
that tells (usually) based on the resource which primary resource reconciliation to trigger.
38
-
The mapping is usually done based on the owner reference or annotation on the secondary resource.
39
-
(But not always, as we will see)
33
+
The key question is: how do you trigger reconciliation of a primary resource (your custom resource)
34
+
when an Informer receives a new resource?
35
+
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)
36
+
to determine which primary resource reconciliation to trigger based on the received resource.
37
+
This mapping is typically done using owner references or annotations on the secondary resource,
38
+
though other mapping strategies are possible (as we'll see later).
40
39
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 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`.
40
+
It's important to understand that when a resource triggers reconciliation of a primary resource,
41
+
that resource will naturally be needed during the reconciliation process, so the reconciler must be able to access it.
42
+
Therefore, InformerEventSource maintains a reverse index called [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),
43
+
which is built based on the results of the `SecondaryToPrimaryMapper`.
45
44
46
45
## Unified API for Related Resources
47
46
48
-
To access all related resources for a primary resource, the framework provides an API to access the related
49
-
secondary resources using:
47
+
To access all related resources for a primary resource, the framework provides a unified API:
0 commit comments