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: CONTRIBUTING.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,6 @@
2
2
3
3
Do not open pull requests directly against this repository, they will be ignored. Instead, please open pull requests against [kubernetes/kubernetes](https://git.k8s.io/kubernetes/). Please follow the same [contributing guide](https://git.k8s.io/kubernetes/CONTRIBUTING.md) you would follow for any other pull request made to kubernetes/kubernetes.
4
4
5
-
This repository is published from [kubernetes/kubernetes/staging/src/k8s.io/sample-controller](https://git.k8s.io/kubernetes/staging/src/k8s.io/sample-controller) by the [kubernetes publishing-bot](https://git.k8s.io/publishing-bot).
5
+
This repository is published from [kubernetes/kubernetes/staging/src/k8s.io/sample-controller](https://git.k8s.io/kubernetes/staging/src/k8s.io/sample-controller) by the [kubernetes publishing-bot](https://git.k8s.io/publishing-bot).
6
6
7
7
Please see [Staging Directory and Publishing](https://git.k8s.io/community/contributors/devel/sig-architecture/staging.md) for more information
Copy file name to clipboardExpand all lines: docs/controller-client-go.md
+16-16
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,11 @@
1
1
# client-go under the hood
2
2
3
-
The [client-go](https://github.com/kubernetes/client-go/) library contains various mechanisms that you can use when
4
-
developing your custom controllers. These mechanisms are defined in the
3
+
The [client-go](https://github.com/kubernetes/client-go/) library contains various mechanisms that you can use when
4
+
developing your custom controllers. These mechanisms are defined in the
5
5
[tools/cache folder](https://github.com/kubernetes/client-go/tree/master/tools/cache) of the library.
6
6
7
-
Here is a pictorial representation showing how the various components in
8
-
the client-go library work and their interaction points with the custom
7
+
Here is a pictorial representation showing how the various components in
8
+
the client-go library work and their interaction points with the custom
9
9
controller code that you will write.
10
10
11
11
<palign="center">
@@ -19,7 +19,7 @@ watches the Kubernetes API for the specified resource type (kind).
19
19
The function in which this is done is *ListAndWatch*.
20
20
The watch could be for an in-built resource or it could be for a custom resource.
21
21
When the reflector receives notification about existence of new
22
-
resource instance through the watch API, it gets the newly created object
22
+
resource instance through the watch API, it gets the newly created object
23
23
using the corresponding listing API and puts it in the Delta Fifo queue
24
24
inside the *watchHandler* function.
25
25
@@ -38,27 +38,27 @@ that generates an object’s key as `<namespace>/<name>` combination for that ob
38
38
39
39
## Custom Controller components
40
40
41
-
* Informer reference: This is the reference to the Informer instance that knows
42
-
how to work with your custom resource objects. Your custom controller code needs
41
+
* Informer reference: This is the reference to the Informer instance that knows
42
+
how to work with your custom resource objects. Your custom controller code needs
43
43
to create the appropriate Informer.
44
44
45
-
* Indexer reference: This is the reference to the Indexer instance that knows
46
-
how to work with your custom resource objects. Your custom controller code needs
47
-
to create this. You will be using this reference for retrieving objects for
45
+
* Indexer reference: This is the reference to the Indexer instance that knows
46
+
how to work with your custom resource objects. Your custom controller code needs
47
+
to create this. You will be using this reference for retrieving objects for
48
48
later processing.
49
49
50
50
The base controller in client-go provides the *NewIndexerInformer* function to create Informer and Indexer.
51
51
In your code you can either [directly invoke this function](https://github.com/kubernetes/client-go/blob/master/examples/workqueue/main.go#L174) or [use factory methods for creating an informer.](https://github.com/kubernetes/sample-controller/blob/master/main.go#L61)
52
52
53
-
* Resource Event Handlers: These are the callback functions which will be called by
54
-
the Informer when it wants to deliver an object to your controller. The typical
53
+
* Resource Event Handlers: These are the callback functions which will be called by
54
+
the Informer when it wants to deliver an object to your controller. The typical
55
55
pattern to write these functions is to obtain the dispatched object’s key
56
56
and enqueue that key in a work queue for further processing.
57
57
58
-
* Work queue: This is the queue that you create in your controller code to decouple
59
-
delivery of an object from its processing. Resource event handler functions are written
58
+
* Work queue: This is the queue that you create in your controller code to decouple
59
+
delivery of an object from its processing. Resource event handler functions are written
60
60
to extract the delivered object’s key and add that to the work queue.
61
61
62
-
* Process Item: This is the function that you create in your code which processes items
63
-
from the work queue. There can be one or more other functions that do the actual processing.
62
+
* Process Item: This is the function that you create in your code which processes items
63
+
from the work queue. There can be one or more other functions that do the actual processing.
64
64
These functions will typically use the [Indexer reference](https://github.com/kubernetes/client-go/blob/master/examples/workqueue/main.go#L73), or a Listing wrapper to retrieve the object corresponding to the key.
0 commit comments