@@ -18,21 +18,21 @@ limitations under the License.
18
18
Package pkg provides libraries for building Controllers. Controllers implement Kubernetes APIs
19
19
and are foundational to building Operators, Workload APIs, Configuration APIs, Autoscalers, and more.
20
20
21
- Client
21
+ # Client
22
22
23
23
Client provides a Read + Write client for reading and writing Kubernetes objects.
24
24
25
- Cache
25
+ # Cache
26
26
27
27
Cache provides a Read client for reading objects from a local cache.
28
28
A cache may register handlers to respond to events that update the cache.
29
29
30
- Manager
30
+ # Manager
31
31
32
32
Manager is required for creating a Controller and provides the Controller shared dependencies such as
33
33
clients, caches, schemes, etc. Controllers should be Started through the Manager by calling Manager.Start.
34
34
35
- Controller
35
+ # Controller
36
36
37
37
Controller implements a Kubernetes API by responding to events (object Create, Update, Delete) and ensuring that
38
38
the state specified in the Spec of the object matches the state of the system. This is called a reconcile.
@@ -49,7 +49,7 @@ system must be read for each reconcile.
49
49
50
50
* Controllers require Watches to be configured to enqueue reconcile.Requests in response to events.
51
51
52
- Webhook
52
+ # Webhook
53
53
54
54
Admission Webhooks are a mechanism for extending kubernetes APIs. Webhooks can be configured with target
55
55
event type (object Create, Update, Delete), the API server will send AdmissionRequests to them
@@ -62,7 +62,7 @@ Validating webhook is used to validate if an object meets certain requirements.
62
62
63
63
* Admission Webhooks require Handler(s) to be provided to process the received AdmissionReview requests.
64
64
65
- Reconciler
65
+ # Reconciler
66
66
67
67
Reconciler is a function provided to a Controller that may be called at anytime with the Name and Namespace of an object.
68
68
When called, the Reconciler will ensure that the state of the system matches what is specified in the object at the
@@ -84,7 +84,7 @@ a mapping (e.g. owner references) that maps the object that triggers the reconci
84
84
- e.g. it doesn't matter whether a ReplicaSet was created or updated, Reconciler will always compare the number of
85
85
Pods in the system against what is specified in the object at the time it is called.
86
86
87
- Source
87
+ # Source
88
88
89
89
resource.Source is an argument to Controller.Watch that provides a stream of events.
90
90
Events typically come from watching Kubernetes APIs (e.g. Pod Create, Update, Delete).
@@ -97,7 +97,7 @@ through the Watch API.
97
97
98
98
* Users SHOULD only use the provided Source implementations instead of implementing their own for nearly all cases.
99
99
100
- EventHandler
100
+ # EventHandler
101
101
102
102
handler.EventHandler is an argument to Controller.Watch that enqueues reconcile.Requests in response to events.
103
103
@@ -117,7 +117,7 @@ type - e.g. map a Node event to objects that respond to cluster resize events.
117
117
* Users SHOULD only use the provided EventHandler implementations instead of implementing their own for almost
118
118
all cases.
119
119
120
- Predicate
120
+ # Predicate
121
121
122
122
predicate.Predicate is an optional argument to Controller.Watch that filters events. This allows common filters to be
123
123
reused and composed.
@@ -129,7 +129,7 @@ reused and composed.
129
129
* Users SHOULD use the provided Predicate implementations, but MAY implement additional
130
130
Predicates e.g. generation changed, label selectors changed etc.
131
131
132
- PodController Diagram
132
+ # PodController Diagram
133
133
134
134
Source provides event:
135
135
@@ -143,14 +143,14 @@ Reconciler is called with the Request:
143
143
144
144
* Reconciler(reconcile.Request{types.NamespaceName{Name: "foo", Namespace: "bar"}})
145
145
146
- Usage
146
+ # Usage
147
147
148
148
The following example shows creating a new Controller program which Reconciles ReplicaSet objects in response
149
149
to Pod or ReplicaSet events. The Reconciler function simply adds a label to the ReplicaSet.
150
150
151
151
See the examples/builtins/main.go for a usage example.
152
152
153
- Controller Example
153
+ Controller Example:
154
154
155
155
1. Watch ReplicaSet and Pods Sources
156
156
@@ -167,7 +167,7 @@ Owning ReplicaSet Namespace and Name.
167
167
168
168
2.3 Reconciler triggered by deletion of Pods from some other actor -> Read ReplicaSet and Pods, create replacement Pods.
169
169
170
- Watching and EventHandling
170
+ # Watching and EventHandling
171
171
172
172
Controllers may Watch multiple Kinds of objects (e.g. Pods, ReplicaSets and Deployments), but they reconcile
173
173
only a single Type. When one Type of object must be updated in response to changes in another Type of object,
@@ -185,7 +185,7 @@ Note: reconcile.Requests are deduplicated when they are enqueued. Many Pod Even
185
185
may trigger only 1 reconcile invocation as each Event results in the Handler trying to enqueue
186
186
the same reconcile.Request for the ReplicaSet.
187
187
188
- Controller Writing Tips
188
+ # Controller Writing Tips
189
189
190
190
Reconciler Runtime Complexity:
191
191
0 commit comments