Skip to content

Commit ad8d2cf

Browse files
authored
add placement examples for addon template (#514)
Signed-off-by: Qing Hao <qhao@redhat.com>
1 parent 3aa5e84 commit ad8d2cf

2 files changed

Lines changed: 90 additions & 113 deletions

File tree

content/en/docs/developer-guides/addon.md

Lines changed: 6 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -859,86 +859,9 @@ This architecture graph shows how the coordination between add-on manager and ad
859859

860860
The add-on agent lifecycle can now be managed by the general
861861
`addon-manager` starting from OCM v0.11.0. This is achieved through enhancements
862-
to the `ClusterManagementAddOn` and `ManagedClusterAddOn` APIs.
862+
to the `ClusterManagementAddOn` and `ManagedClusterAddOn` APIs.
863863

864-
1. Install strategy
865-
866-
With the install strategy defined in the `ClusterManagementAddOn` API, users can
867-
configure which clusters the related `ManagedClusterAddon` should be enabled by
868-
referencing the `Placement`. For example, enabling the `helloworld` add-on on
869-
clusters labeled with aws.
870-
871-
```yaml
872-
apiVersion: addon.open-cluster-management.io/v1alpha1
873-
kind: ClusterManagementAddOn
874-
metadata:
875-
name: helloworld
876-
annotations:
877-
addon.open-cluster-management.io/lifecycle: "addon-manager"
878-
spec:
879-
addOnMeta:
880-
displayName: helloworld
881-
installStrategy:
882-
type: Placements
883-
placements:
884-
- name: placement-aws
885-
namespace: default
886-
```
887-
888-
```yaml
889-
apiVersion: cluster.open-cluster-management.io/v1beta1
890-
kind: Placement
891-
metadata:
892-
name: placement-aws
893-
namespace: default
894-
spec:
895-
predicates:
896-
- requiredClusterSelector:
897-
claimSelector:
898-
matchExpressions:
899-
- key: platform.open-cluster-management.io
900-
operator: In
901-
values:
902-
- aws
903-
```
904-
905-
2. Rollout strategy
906-
907-
With the rollout strategy defined in the `ClusterManagementAddOn` API, users can
908-
control the upgrade behavior of the add-on when there are changes in the [supported configurations](#add-your-add-on-agent-supported-configurations).
909-
910-
For example, if the add-on user updates the "deploy-config" and wants to apply
911-
the change to the add-ons to a "canary" [decision group](https://open-cluster-management.io/concepts/placement/#decision-strategy) first.
912-
If all the add-on upgrade successfully, then upgrade the rest of clusters progressively per cluster
913-
at a rate of 25%. The rollout strategy can be defined as follows:
914-
915-
```yaml
916-
apiVersion: addon.open-cluster-management.io/v1alpha1
917-
kind: ClusterManagementAddOn
918-
metadata:
919-
name: helloworld
920-
annotations:
921-
addon.open-cluster-management.io/lifecycle: "addon-manager"
922-
spec:
923-
addOnMeta:
924-
displayName: helloworld
925-
installStrategy:
926-
type: Placements
927-
placements:
928-
- name: placement-aws
929-
namespace: default
930-
configs:
931-
- group: addon.open-cluster-management.io
932-
resource: addondeploymentconfigs
933-
name: deploy-config
934-
namespace: open-cluster-management
935-
rolloutStrategy:
936-
type: Progressive
937-
progressive:
938-
mandatoryDecisionGroups:
939-
- groupName: "canary"
940-
maxConcurrency: 25%
941-
```
864+
More detailed usage of add-on install strategy and rollout strategy refer to the [Add-on lifecycle management](https://open-cluster-management.io/docs/getting-started/installation/addon-management/#add-on-lifecycle-management).
942865

943866
Add-on developers can use addon-framework v0.9.3 and the above versions
944867
to support the scenarios mentioned above.
@@ -1505,3 +1428,7 @@ namespace, and mount the configmap to the addon agent deployments and daemonsets
15051428
`CA_BUNDLE_FILE_PATH` to the file path of the mounted ca bundle. If the addon needs to support the `caBundle` for the
15061429
`proxyConfig`, the **addon developer should get the ca bundle from the environment variable** `CA_BUNDLE_FILE_PATH`
15071430
to make the agent work with the proxy.
1431+
1432+
### Add-on template configurations
1433+
1434+
[Add-on configurations](https://open-cluster-management.io/docs/getting-started/installation/addon-management/#add-on-configurations) provides examples of how to configure add-on templates for different use cases.

content/en/docs/getting-started/installation/addon-management.md

Lines changed: 84 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ the default add-on configuration. In scenarios where all add-ons have the same
182182
configuration. Only one configuration of the same group and resource can be specified
183183
in the `defaultConfig`.
184184

185-
In the example below, add-ons on all the clusters will use "default-deploy-config" and "default-example-config".
185+
In the example below, add-ons on all the clusters will use "default-deploy-config" and "default-addon-template".
186186

187187
```yaml
188188
apiVersion: addon.open-cluster-management.io/v1alpha1
@@ -201,23 +201,23 @@ spec:
201201
group: addon.open-cluster-management.io
202202
resource: addondeploymentconfigs
203203
- defaultConfig:
204-
name: default-example-config
204+
name: default-addon-template
205205
namespace: open-cluster-management
206-
group: example.open-cluster-management.io
207-
resource: exampleconfigs
206+
group: addon.open-cluster-management.io
207+
resource: addontemplates
208208
```
209209

210210
### Configurations per install strategy
211211

212212
In `ClusterManagementAddOn`, `spec.installStrategy.placements[].configs` lists the
213213
configuration of `ManagedClusterAddon` during installation for a group of clusters.
214214
For the need to use multiple configurations with the same group and resource can be defined
215-
in this field since OCM v0.15.0. It will override the [Default configurations](#default-configurations)
216-
on certain clusters by group and resource.
215+
in this field since OCM v0.15.0. If [Default configurations](#default-configurations) is defined,
216+
it will override the [Default configurations](#default-configurations) on certain clusters by group and resource.
217217

218-
In the example below, add-ons on clusters selected by `Placement` placement-aws will
219-
use "deploy-config", "example-config-1" and "example-config-2", while all the other add-ons
220-
will still use "default-deploy-config" and "default-example-config".
218+
In the example below, add-ons on clusters selected by `Placement` will
219+
use "override-deploy-config" and "override-addon-template", while all the other add-ons
220+
will still use "default-deploy-config" and "default-addon-template".
221221

222222
```yaml
223223
apiVersion: addon.open-cluster-management.io/v1alpha1
@@ -235,26 +235,76 @@ spec:
235235
namespace: open-cluster-management
236236
group: addon.open-cluster-management.io
237237
resource: addondeploymentconfigs
238+
- defaultConfig:
239+
name: default-addon-template
240+
namespace: open-cluster-management
241+
group: addon.open-cluster-management.io
242+
resource: addontemplates
238243
installStrategy:
239244
type: Placements
240245
placements:
241-
- name: placement-aws
242-
namespace: default
246+
- name: <placement-name>
247+
namespace: <placement-namespace>
243248
configs:
244-
- group: addon.open-cluster-management.io
245-
resource: addondeploymentconfigs
246-
name: deploy-config
247-
namespace: open-cluster-management
248-
- group: example.open-cluster-management.io
249-
resource: exampleconfigs
250-
name: example-config-1
249+
- name: override-deploy-config
251250
namespace: open-cluster-management
252-
- group: example.open-cluster-management.io
253-
resource: exampleconfigs
254-
name: example-config-2
251+
group: addon.open-cluster-management.io
252+
resource: addondeploymentconfigs
253+
- name: override-addon-template
255254
namespace: open-cluster-management
255+
group: addon.open-cluster-management.io
256+
resource: addontemplates
257+
```
258+
259+
Below are some recommended `Placement` for the install strategy:
260+
261+
- To apply the same configuration across all `ManagedCluster`, use [Default configurations](#default-configurations).
262+
263+
- To apply the configuration to the hub cluster, it must have a specific identifying label or claim, such as local-cluster: "true", for example:
264+
265+
```yaml
266+
apiVersion: cluster.open-cluster-management.io/v1beta1
267+
kind: Placement
268+
metadata:
269+
name: <placement-name>
270+
namespace: <placement-namespace>
271+
spec:
272+
predicates:
273+
- requiredClusterSelector:
274+
labelSelector:
275+
matchLabels:
276+
local-cluster: "true"
277+
```
278+
279+
- To apply the configuration to the spoke clusters, use the following `Placement`:
280+
281+
```yaml
282+
apiVersion: cluster.open-cluster-management.io/v1beta1
283+
kind: Placement
284+
metadata:
285+
name: <placement-name>
286+
namespace: <placement-namespace>
287+
spec:
288+
predicates:
289+
- requiredClusterSelector:
290+
labelSelector:
291+
matchExpressions:
292+
- key: local-cluster
293+
operator: NotIn
294+
values:
295+
- "true"
296+
# Uncomment the following to install even when clusters are unreachable or unavailable.
297+
# tolerations:
298+
# - key: cluster.open-cluster-management.io/unreachable
299+
# operator: Equal
300+
# - key: cluster.open-cluster-management.io/unavailable
301+
# operator: Equal
256302
```
257303

304+
- To apply the configuration to a specific set of clusters, see [Placement](https://open-cluster-management.io/docs/concepts/content-placement/placement/) for more options.
305+
306+
- To apply the configuration to a single specific cluster, see the next section [Configurations per cluster](#configurations-per-cluster).
307+
258308
### Configurations per cluster
259309

260310
In `ManagedClusterAddOn`, `spec.configs` is a list of add-on configurations.
@@ -264,7 +314,7 @@ It will override the [Default configurations](#default-configurations) and
264314
[Configurations per install strategy](#configurations-per-install-strategy) defined
265315
in `ClusterManagementAddOn` by group and resource.
266316

267-
In the below example, add-on on cluster1 will use "cluster1-deploy-config" and "cluster1-example-config".
317+
In the below example, add-on on cluster1 will use "cluster1-deploy-config" and "cluster1-addon-template".
268318

269319
```yaml
270320
apiVersion: addon.open-cluster-management.io/v1alpha1
@@ -274,14 +324,14 @@ metadata:
274324
namespace: cluster1
275325
spec:
276326
configs:
277-
- group: addon.open-cluster-management.io
278-
resource: addondeploymentconfigs
279-
name: cluster1-deploy-config
327+
- name: cluster1-deploy-config
280328
namespace: open-cluster-management
281-
- group: example.open-cluster-management.io
282-
resource: exampleconfigs
283-
name: cluster1-example-config
329+
group: addon.open-cluster-management.io
330+
resource: addondeploymentconfigs
331+
- name: cluster1-addon-template
284332
namespace: open-cluster-management
333+
group: addon.open-cluster-management.io
334+
resource: addontemplates
285335
```
286336

287337
### Supported configurations
@@ -302,8 +352,8 @@ status:
302352
supportedConfigs:
303353
- group: addon.open-cluster-management.io
304354
resource: addondeploymentconfigs
305-
- group: example.open-cluster-management.io
306-
resource: exampleconfigs
355+
- group: addon.open-cluster-management.io
356+
resource: addontemplates
307357
```
308358

309359
### Effective configurations
@@ -329,15 +379,15 @@ status:
329379
...
330380
configReferences:
331381
- desiredConfig:
332-
name: cluster1-deploy-config
382+
name: cluster1-addon-template
333383
namespace: open-cluster-management
334384
specHash: dcf88f5b11bd191ed2f886675f967684da8b5bcbe6902458f672277d469e2044
335385
group: addon.open-cluster-management.io
336386
lastAppliedConfig:
337-
name: cluster1-deploy-config
387+
name: cluster1-addon-template
338388
namespace: open-cluster-management
339389
specHash: dcf88f5b11bd191ed2f886675f967684da8b5bcbe6902458f672277d469e2044
340390
lastObservedGeneration: 1
341-
name: cluster1-deploy-config
342-
resource: addondeploymentconfigs
391+
name: cluster1-addon-template
392+
resource: addontemplates
343393
```

0 commit comments

Comments
 (0)