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
@@ -59,7 +64,7 @@ To achieve this, ClusterResourceSet CRD is introduced that will be responsible f
59
64
60
65
### Goals
61
66
62
-
- Provide a means to specify a set of resources to apply automatically to newly-created and existing Clusters. Resources will be applied only once.
67
+
- Provide a means to specify a set of resources to apply automatically to newly-created and existing Clusters. Resources will be reapplied when their definition changes.
63
68
- Support additions to the resource list by applying the new added resources to both new and existing matching clusters.
64
69
- Provide a way to see which ClusterResourceSets are applied to a particular cluster using a new CRD, `ClusterResourceSetBinding`.
65
70
- Support both json and yaml resources.
@@ -69,7 +74,6 @@ To achieve this, ClusterResourceSet CRD is introduced that will be responsible f
69
74
- Replace or compete with the Cluster Addons subproject.
70
75
- Support deletion of resources from clusters. Deleting a resource from a ClusterResourceSet or deleting a ClusterResourceSet does not result in deletion of those resources from clusters.
71
76
- Lifecycle management of the installed resources (such as CNI).
72
-
- Support reconciliation of resources on resource hash change and/or periodically. This can be a future enhancement work.
73
77
74
78
75
79
## Proposal
@@ -121,13 +125,16 @@ spec:
121
125
kind: ConfigMap
122
126
```
123
127
124
-
Initially, the only supported mode will be `ApplyOnce` and it will be the default mode if no mode is provided. In the future, we may consider adding a `Reconcile` mode that reapplies the resources on resource hash change and/or periodically.
128
+
The supported modes will be:
129
+
* `ApplyOnce`. This will be the default mode if no mode is provided. Resources are only applied once.
130
+
* `Reconcile`. Resources are reapplied when the content of the `ConfigMap` or `Secret` that defines them changes.
131
+
125
132
If ClusterResourceSet resources will be managed by an operator after they are applied by ClusterResourceSet controller, "ApplyOnce" mode must be used so that reconciliation on those resources can be delegated to the operator.
126
133
127
134
Each item in the resources specifies a kind (must be either ConfigMap or Secret) and a name. Each referenced ConfigMap/Secret contains yaml/json content as value.
128
135
`ClusterResourceSet`object will be added as owner to its resources.
129
136
130
-
***Secrets as Resources***
137
+
***Secrets as Resources***
131
138
132
139
Both `Secrets` and `ConfigMaps` `data` fields can be a list of key-value pairs. Any key is acceptable, and as value, there can be multiple objects in yaml or json format.
133
140
@@ -176,7 +183,7 @@ stringData:
176
183
namespace: system
177
184
```
178
185
179
-
***ConfigMaps as Resources***
186
+
***ConfigMaps as Resources***
180
187
181
188
Similar to `Secrets`, `ConfigMaps` can be created using a yaml/json file: `kubectl create configmap calico-addon --from-file=calico1.yaml,calico2.yaml`
182
189
Multiple keys in the data field and then multiple objects in each value are supported.
@@ -253,13 +260,91 @@ When a `ClusterResourceSet` is deleted, it will be removed from the `bindings` l
253
260
In case of new resource addition to a `ClusterResourceSet`, that `ClusterResourceSet` will be reconciled immediately and the new resource will be applied to all matching clusters because
254
261
the new resource does not exist in any `ClusterResourceBinding` lists.
255
262
263
+
#### `ApplyOnce` mode
264
+
256
265
When the same resource exist in multiple `ClusterResourceSets`, only the first one will be applied but the resource will appear as applied in all `ClusterResourceSets` in the `ClusterResourceSetsBinding/bindings`.
257
266
Similarly, if a resource is manually created in the workload cluster, when a `ClusterResourceSet` is applied with that resource, it will not update the existing resource to avoid any overwrites but in `ClusterResourceSetBinding`, that resource will show as applied.
258
267
259
-
As a note, if providing different values for some fields in the resources for different clusters is needed such as CNIs podCIDRs, some templating mechanism for variable substitution in the resources can be used, but not provided by `ClusterResourceSet`.
268
+
#### `Reconcile` mode
269
+
270
+
***Detecting changes***
271
+
`ClusterResourceBindings`will contain consistent hash for the resource/s definitions. We will use this to detect changes, comparing the hash of the current resource/s definition with the one stored in the `ClusterResourceBindings`.
272
+
273
+
Note that this hash will change when any of the resources is updated, a resource is added or a resource is removed. This means that all resources in the same `ConfigMap` or `Secret`, and not only the one that changed, will be reapplied in any of these 3 cases. It also means that resources removed from `ConfigMap` or `Secret` won't be deleted from the target clusters.
274
+
275
+
In the next *before-after* example we can see that only one resource has changed (`ConfigMap` `calico-configmap`). However, all the 3 resources (`calico-secret1`, `calico-secret2` and `calico-configmap`) will be reapplied.
276
+
277
+
Before:
278
+
```yaml
279
+
apiVersion: v1
280
+
kind: ConfigMap
281
+
metadata:
282
+
name: calico-addon
283
+
data:
284
+
calico1.yaml: |-
285
+
kind: Secret
286
+
apiVersion: v1
287
+
metadata:
288
+
name: calico-secret1
289
+
namespace: mysecrets
290
+
---
291
+
kind: Secret
292
+
apiVersion: v1
293
+
metadata:
294
+
name: calico-secret2
295
+
namespace: mysecrets
296
+
calico2.yaml: |-
297
+
kind: ConfigMap
298
+
apiVersion: v1
299
+
metadata:
300
+
name: calico-configmap
301
+
namespace: myconfigmaps
302
+
data:
303
+
key: "original value"
304
+
```
305
+
306
+
After:
307
+
```yaml
308
+
apiVersion: v1
309
+
kind: ConfigMap
310
+
metadata:
311
+
name: calico-addon
312
+
data:
313
+
calico1.yaml: |-
314
+
kind: Secret
315
+
apiVersion: v1
316
+
metadata:
317
+
name: calico-secret1
318
+
namespace: mysecrets
319
+
---
320
+
kind: Secret
321
+
apiVersion: v1
322
+
metadata:
323
+
name: calico-secret2
324
+
namespace: mysecrets
325
+
calico2.yaml: |-
326
+
kind: ConfigMap
327
+
apiVersion: v1
328
+
metadata:
329
+
name: calico-configmap
330
+
namespace: myconfigmaps
331
+
data:
332
+
key: "value that changed"
333
+
```
260
334
261
335
### Risks and Mitigations
262
336
337
+
#### Drift
338
+
339
+
The proposed solution only deals with changes in the resources' definitions and not with changes in the real objects in the workload clusters. If those objects are modified or deleted in the workload clusters, the `ClusterResourceSet`'s controller won't do anything and they will remain unchanged until their definition in the management cluster is updated.
340
+
341
+
This could potentially be mitigated by:
342
+
* Implementing a "periodic" reconciliation mode where resources are reapplied with a certain frequency even if their hash hasn't changed.
343
+
344
+
#### Deletion
345
+
346
+
Resource deletion is not supported. If a resource is removed from a `ConfigMap` or `Secret`, the hash for the CRS will change so the resources that haven't been removed will be reapplied. However, the removed resourced won't be deleted.
347
+
263
348
## Alternatives
264
349
265
350
The Alternatives section is used to highlight and record other possible approaches to delivering the value proposed by a proposal.
0 commit comments