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/concepts/Override/README.md
+47-1Lines changed: 47 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,10 @@ and `ResourceOverride`.
36
36
- At most 100 `ClusterResourceOverride` can be created.
37
37
- At most 100 `ResourceOverride` can be created.
38
38
39
+
## Placement
40
+
41
+
This specifies which placement the override should be applied to.
42
+
39
43
## Resource Selector
40
44
`ClusterResourceSelector` of `ClusterResourceOverride` selects which cluster-scoped resources need to be overridden before
41
45
applying to the selected clusters.
@@ -64,14 +68,52 @@ Each override rule contains the following fields:
64
68
- Select clusters by specifying the cluster labels.
65
69
- An empty selector selects ALL the clusters.
66
70
- A nil selector selects NO target cluster.
67
-
-`JSONPatchOverrides`: a list of JSON path override rules applied to the selected resources following [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902).
71
+
-`OverrideType`: which type of the override should be applied to the selected resources. The default type is `JSONPatch`.
72
+
-`JSONPatch`: applies the JSON patch to the selected resources using [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902).
73
+
-`Delete`: deletes the selected resources on the target cluster.
74
+
-`JSONPatchOverrides`: a list of JSON path override rules applied to the selected resources following [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902) when the override type is `JSONPatch`.
68
75
69
76
> **Note:** Updating the fields in the TypeMeta (e.g., `apiVersion`, `kind`) is not allowed.
70
77
71
78
> **Note:** Updating the fields in the ObjectMeta (e.g., `name`, `namespace`) excluding annotations and labels is not allowed.
72
79
73
80
> **Note:** Updating the fields in the Status (e.g., `status`) is not allowed.
74
81
82
+
### Reserved Variables in the JSON Patch Override Value
83
+
84
+
There is a list of reserved variables that will be replaced by the actual values used in the `value` of the JSON patch override rule:
85
+
*`${MEMBER-CLUSTER-NAME}`: this will be replaced by the name of the `memberCluster` that represents this cluster.
86
+
87
+
For example, to add a label to the `ClusterRole` named `secret-reader` on clusters with the label `env: prod`,
The `ClusterResourceOverride` object above will add a label `cluster-name` with the value of the `memberCluster` name to the `ClusterRole` named `secret-reader` on clusters with the label `env: prod`.
116
+
75
117
## When To Trigger Rollout
76
118
77
119
It will take the snapshot of each override change as a result of `ClusterResourceOverrideSnapshot` and
Copy file name to clipboardExpand all lines: docs/howtos/cluster-resource-override.md
+82-5Lines changed: 82 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,12 +11,17 @@ parameters, ensuring consistent management and enforcement of configurations acr
11
11
12
12
## API Components
13
13
The ClusterResourceOverride API consists of the following components:
14
+
-**Placement**: This specifies which placement the override is applied to.
14
15
-**Cluster Resource Selectors**: These specify the set of cluster resources selected for overriding.
15
16
-**Policy**: This specifies the policy to be applied to the selected resources.
16
17
17
18
18
19
The following sections discuss these components in depth.
19
20
21
+
## Placement
22
+
23
+
To configure which placement the override is applied to, you can use the name of `ClusterResourcePlacement`.
24
+
20
25
## Cluster Resource Selectors
21
26
A `ClusterResourceOverride` object may feature one or more cluster resource selectors, specifying which resources to select to be overridden.
22
27
@@ -61,7 +66,10 @@ resources on selected clusters.
61
66
62
67
Each `OverrideRule` supports the following fields:
63
68
- **Cluster Selector**: This specifies the set of clusters to which the override applies.
64
-
- **JSON Patch Override**: This specifies the changes to be applied to the selected resources.
69
+
- **Override Type**: This specifies the type of override to be applied. The default type is `JSONPatch`.
70
+
- `JSONPatch`: applies the JSON patch to the selected resources using [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902).
71
+
- `Delete`: deletes the selected resources on the target cluster.
72
+
- **JSON Patch Override**: This specifies the changes to be applied to the selected resources when the override type is `JSONPatch`.
65
73
66
74
To add an override rule, edit the `policy` field in the `ClusterResourceOverride` spec:
67
75
```yaml
@@ -70,6 +78,8 @@ kind: ClusterResourceOverride
70
78
metadata:
71
79
name: example-cro
72
80
spec:
81
+
placement:
82
+
name: crp-example
73
83
clusterResourceSelectors:
74
84
- group: rbac.authorization.k8s.io
75
85
kind: ClusterRole
@@ -87,7 +97,7 @@ spec:
87
97
path: /rules/0/verbs/2
88
98
```
89
99
The `ClusterResourceOverride` object above will remove the verb "list" in the `ClusterRole` named `secret-reader` on
90
-
clusters with the label `env: prod`.
100
+
clusters with the label `env: prod` selected by the clusterResourcePlacement `crp-example`.
91
101
92
102
> The ClusterResourceOverride mentioned above utilizes the cluster role displayed below:
93
103
> ```
@@ -100,12 +110,42 @@ clusters with the label `env: prod`.
100
110
> secrets [] [] [get watch list]
101
111
>```
102
112
113
+
To delete the `secret-reader` on the clusters with the label `env: test` selected by the clusterResourcePlacement `crp-example`, you can use the `Delete` override type.
The `ClusterResourceOverride` object above will add a label `cluster-name` with the value of the `memberCluster` name to the `ClusterRole` named `secret-reader` on clusters with the label `env: prod`.
140
211
141
212
### Multiple Override Patches
142
213
You may add multiple `JSONPatchOverride` to an `OverrideRule` to apply multiple changes to the selected cluster resources.
@@ -146,6 +217,8 @@ kind: ClusterResourceOverride
146
217
metadata:
147
218
name: example-cro
148
219
spec:
220
+
placement:
221
+
name: crp-example
149
222
clusterResourceSelectors:
150
223
- group: rbac.authorization.k8s.io
151
224
kind: ClusterRole
@@ -210,6 +283,9 @@ spec:
210
283
- labelSelector:
211
284
matchLabels:
212
285
env: prod
286
+
- labelSelector:
287
+
matchLabels:
288
+
env: test
213
289
```
214
290
The `ClusterResourcePlacement` configuration outlined above will disperse resources across all clusters labeled with `env: prod`.
215
291
As the changes are implemented, the corresponding `ClusterResourceOverride` configurations will be applied to the
@@ -245,7 +321,7 @@ Status:
245
321
...
246
322
```
247
323
Each cluster maintains its own `Applicable Cluster Resource Overrides` which contain the cluster resource override snapshot
248
-
if relevant. Additionally, individual status messages for each cluster indicates whether the override rules have been
324
+
if relevant. Additionally, individual status messages for each cluster indicate whether the override rules have been
249
325
effectively applied.
250
326
251
327
The `ClusterResourcePlacementOverridden` condition indicates whether the resource override has been successfully applied
@@ -260,7 +336,7 @@ check resources in the selected clusters:
260
336
`kubectl --context=<member-cluster-context> get clusterrole secret-reader -o yaml`
261
337
262
338
Upon inspecting the described ClusterRole object, it becomes apparent that the verbs "watch" and "list" have been
263
-
removed from the permissions list within the ClusterRole named "secret-reader" on the selected cluster.
339
+
removed from the permissions list within the ClusterRole named "secret-reader" on the prod clusters.
264
340
```
265
341
apiVersion: rbac.authorization.k8s.io/v1
266
342
kind: ClusterRole
@@ -273,4 +349,5 @@ removed from the permissions list within the ClusterRole named "secret-reader" o
273
349
- secrets
274
350
verbs:
275
351
- get
276
-
```
352
+
```
353
+
Similarly, you can verify that this cluster role does not exist in the test clusters.
0 commit comments