diff --git a/content/en/docs/concepts/override.md b/content/en/docs/concepts/override.md index 1df3816..f4f08b5 100644 --- a/content/en/docs/concepts/override.md +++ b/content/en/docs/concepts/override.md @@ -135,6 +135,8 @@ spec: {"cluster-name":"${MEMBER-CLUSTER-NAME}"} ``` +> Note: Using `op: add` with the path `/metadata/labels` (pointing to the entire labels map) will **replace all existing labels** with the value provided. To add a single label without affecting existing ones, use a more specific path such as `/metadata/labels/cluster-name`. + 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`. #### Example: Using `${MEMBER-CLUSTER-LABEL-KEY-...}` in a `ClusterResourceOverride` @@ -165,6 +167,8 @@ spec: value: "${MEMBER-CLUSTER-LABEL-KEY-region}" ``` +> Note: To replace an existing label value, use `op: replace` instead (e.g., `op: replace` with path `/metadata/labels/cluster-region`). However, `op: replace` will fail with an error if the label does not already exist on the resource. + When applied to a cluster with the label `region: us-west`, the `ClusterRole` will receive the label `cluster-region: us-west`. When applied to a cluster with `region: eu-central`, the label will be `cluster-region: eu-central`. diff --git a/content/en/docs/how-tos/cluster-resource-override.md b/content/en/docs/how-tos/cluster-resource-override.md index 9a92ca5..d5e14a9 100644 --- a/content/en/docs/how-tos/cluster-resource-override.md +++ b/content/en/docs/how-tos/cluster-resource-override.md @@ -168,7 +168,7 @@ spec: {"cluster-name":"${MEMBER-CLUSTER-NAME}"} ``` -> Note: To add a new label to the existing labels, please use the below configuration: +> Note: Using `op: add` with the path `/metadata/labels` (pointing to the entire labels map) will **replace all existing labels** with the value provided. To add a new label to the existing labels, please use the below configuration: > > ```yaml > - op: add @@ -208,6 +208,8 @@ spec: When applied to a cluster with the label `region: us-west`, the `ClusterRole` will receive the label `cluster-region: us-west`. +> Note: To replace an existing label value, use `op: replace` instead (e.g., `op: replace` with path `/metadata/labels/cluster-region`). However, `op: replace` will fail with an error if the label does not already exist on the resource. + You can also use multiple label variables together. For example, to add annotations sourced from cluster labels: ```yaml diff --git a/content/en/docs/how-tos/resource-override.md b/content/en/docs/how-tos/resource-override.md index 0918f32..093e6f9 100644 --- a/content/en/docs/how-tos/resource-override.md +++ b/content/en/docs/how-tos/resource-override.md @@ -207,7 +207,7 @@ spec: {"cluster-name":"${MEMBER-CLUSTER-NAME}"} ``` -> Note: To add a new label to the existing labels, please use the below configuration: +> Note: Using `op: add` with the path `/metadata/labels` (pointing to the entire labels map) will **replace all existing labels** with the value provided. To add a new label to the existing labels, please use the below configuration: > > ```yaml > - op: add