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: README.md
+62-10Lines changed: 62 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,23 @@ This library layers on top of the Operator SDK and with the objective of helping
13
13
14
14
This library covers three main areas:
15
15
16
-
1.[Idempotent methods](#Idempotent-Methods-to-Manipulate-Resources) to manipulate resources and arrays of resources
17
-
2.[Basic operator lifecycle](#Basic-Operator-Lifecycle-Management) needs (validation, initialization, status and error management, finalization)
18
-
3.[Enforcing resources operator support](#Enforcing-Resource-Operator-Support). For those operators which calculate a set of resources that need to exist and then enforce them, generalized support for the enforcing phase is provided.
16
+
1.[Utility Methods](#Utility-Methods) Utility methods that are callable by any operator.
17
+
2.[Idempotent methods](#Idempotent-Methods-to-Manipulate-Resources) to manipulate resources and arrays of resources
18
+
3.[Basic operator lifecycle](#Basic-Operator-Lifecycle-Management) needs (validation, initialization, status and error management, finalization)
19
+
4.[Enforcing resources operator support](#Enforcing-Resource-Operator-Support). For those operators which calculate a set of resources that need to exist and then enforce them, generalized support for the enforcing phase is provided.
20
+
21
+
## Utility Methods
22
+
23
+
Prior to version v2.x the general philosophy of this library was that new operator would inherit from `ReconcilerBase` and in doing so they would have access to a bunch of utility methods.
24
+
With release v2.0.0 a new approach is available. Utility methods are callable by any operator having to inherit. This makes it easier to use this library and does not conflict with autogenerate code from `kube-builder` and `operator-sdk`.
25
+
Most of the Utility methods receive a context.Context parameter. Normally this context must be initialized with a `logr.Logger` and a `rest.Config`. Some utility methods may require more, see each individual documentation.
26
+
27
+
Utility methods are currently organized in the following folders:
2. discoveryclient: methods related to the discovery client, typically used to load `apiResource` objects.
31
+
3. dynamicclient: methods related to building client based on object whose type is not known at compile time.
32
+
4. templates: utility methods for dealing with templates whose output is an object or a list of objects.
19
33
20
34
## Idempotent Methods to Manipulate Resources
21
35
@@ -29,6 +43,15 @@ Also there are utility methods to manage finalizers, test ownership and process
29
43
30
44
## Basic Operator Lifecycle Management
31
45
46
+
---
47
+
48
+
Note
49
+
50
+
This part of the library is largely deprecated. For initialization and defaulting a MutatingWebHook should be used. For validation a Validating WebHook should be used.
51
+
The part regarding the finalization is still relevant.
52
+
53
+
---
54
+
32
55
To get started with this library do the following:
33
56
34
57
Change your reconciler initialization as exemplified below to add a set of utility methods to it
| yes | null | not null | multiple selection across namespaces where the name corresponds to the passed name |
333
+
| yes | not null | null | multiple selection within a namespace |
334
+
| yes | not null | not nul | single selection |
335
+
| no | N/A | null | multiple selection |
336
+
| no | N/A | not null | single selection |
337
+
338
+
Selection can be further narrowed down by filtering by labels and/or annotations. The patch will be applied to all of the selected instances.
339
+
340
+
Name and Namespace of sourceRefObjects are interpreted as golang templates with the current target instance and the only parameter. This allows to select different source object for each target object.
341
+
301
342
The relevant part of the operator code would look like this:
// EnforcingReconcileStatusAware is an interfce that must be implemented by a CRD type that has been enabled with ReconcileStatus, it can then benefit of a series of utility methods.
0 commit comments