-
Notifications
You must be signed in to change notification settings - Fork 1.9k
TELCODOCS-1178: Remove content from a CR on managed clusters #62775
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
127 changes: 127 additions & 0 deletions
127
modules/ztp-removing-content-from-managed-clusters.adoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| // Module included in the following assemblies: | ||
| // | ||
| // * scalability_and_performance/ztp_far_edge/ztp-configuring-managed-clusters-policies.adoc | ||
|
|
||
| :_content-type: PROCEDURE | ||
| [id="ztp-removing-content-from-managed-clusters_{context}"] | ||
| = Changing applied managed cluster CRs using policies | ||
|
|
||
| You can remove content from a custom resource (CR) that is deployed in a managed cluster through a policy. | ||
|
|
||
| By default, all `Policy` CRs created from a `PolicyGenTemplate` CR have the `complianceType` field set to `musthave`. | ||
| A `musthave` policy without the removed content is still compliant because the CR on the managed cluster has all the specified content. | ||
| With this configuration, when you remove content from a CR, {cgu-operator} removes the content from the policy but the content is not removed from the CR on the managed cluster. | ||
|
|
||
| With the `complianceType` field to `mustonlyhave`, the policy ensures that the CR on the cluster is an exact match of what is specified in the policy. | ||
|
|
||
| .Prerequisites | ||
|
|
||
| * You have installed the OpenShift CLI (`oc`). | ||
|
|
||
| * You have logged in to the hub cluster as a user with `cluster-admin` privileges. | ||
amolnar-gh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| * You have deployed a managed cluster from a hub cluster running {rh-rhacm}. | ||
|
|
||
| * You have installed {cgu-operator-full} on the hub cluster. | ||
|
|
||
| .Procedure | ||
|
|
||
| . Remove the content that you no longer need from the affected CRs. In this example, the `disableDrain: false` line was removed from the `SriovOperatorConfig` CR. | ||
| + | ||
| .Example CR | ||
|
|
||
| [source,yaml] | ||
| ---- | ||
amolnar-gh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| apiVersion: sriovnetwork.openshift.io/v1 | ||
| kind: SriovOperatorConfig | ||
| metadata: | ||
| name: default | ||
| namespace: openshift-sriov-network-operator | ||
| spec: | ||
| configDaemonNodeSelector: | ||
| "node-role.kubernetes.io/$mcp": "" | ||
| disableDrain: true | ||
| enableInjector: true | ||
| enableOperatorWebhook: true | ||
| ---- | ||
|
|
||
| . Change the `complianceType` of the affected policies to `mustonlyhave` in the `group-du-sno-ranGen.yaml` file. | ||
| + | ||
| .Example YAML | ||
| [source,yaml] | ||
| ---- | ||
| # ... | ||
| - fileName: SriovOperatorConfig.yaml | ||
amolnar-gh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| policyName: "config-policy" | ||
| complianceType: mustonlyhave | ||
| # ... | ||
| ---- | ||
|
|
||
| . Create a `ClusterGroupUpdates` CR and specify the clusters that must receive the CR changes:: | ||
| + | ||
| .Example ClusterGroupUpdates CR | ||
| [source,yaml] | ||
| ---- | ||
| apiVersion: ran.openshift.io/v1alpha1 | ||
| kind: ClusterGroupUpgrade | ||
| metadata: | ||
| name: cgu-remove | ||
| namespace: default | ||
| spec: | ||
| managedPolicies: | ||
| - ztp-group.group-du-sno-config-policy | ||
| enable: false | ||
| clusters: | ||
| - spoke1 | ||
| - spoke2 | ||
| remediationStrategy: | ||
| maxConcurrency: 2 | ||
| timeout: 240 | ||
| batchTimeoutAction: | ||
| ---- | ||
|
|
||
| . Create the `ClusterGroupUpgrade` CR by running the following command: | ||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ oc create -f cgu-remove.yaml | ||
| ---- | ||
|
|
||
| . When you are ready to apply the changes, for example, during an appropriate maintenance window, change the value of the `spec.enable` field to `true` by running the following command: | ||
amolnar-gh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ oc --namespace=default patch clustergroupupgrade.ran.openshift.io/cgu-remove \ | ||
| --patch '{"spec":{"enable":true}}' --type=merge | ||
| ---- | ||
|
|
||
| .Verification | ||
|
|
||
| . Check the status of the policies by running the following command: | ||
amolnar-gh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ oc get <kind> <changed_cr_name> | ||
| ---- | ||
|
|
||
amolnar-gh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| + | ||
| .Example output | ||
| [source,terminal] | ||
| ---- | ||
| NAMESPACE NAME REMEDIATION ACTION COMPLIANCE STATE AGE | ||
| default cgu-ztp-group.group-du-sno-config-policy enforce 17m | ||
| default ztp-group.group-du-sno-config-policy inform NonCompliant 15h | ||
| ---- | ||
|
|
||
amolnar-gh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| + | ||
| When the `COMPLIANCE STATE` of the policy is `Compliant`, it means that the CR is updated and the unwanted content is removed. | ||
|
|
||
| . Check that the policies are removed from the targeted clusters by running the following command on the managed clusters: | ||
amolnar-gh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| + | ||
| [source,terminal] | ||
| ---- | ||
| $ oc get <kind> <changed_cr_name> | ||
| ---- | ||
|
|
||
amolnar-gh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| + | ||
| If there are no results, the CR is removed from the managed cluster. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.