|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// storage/persistent_storage/persistent_storage_local/persistent-storage-using-lvms.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="lvms-deleting-lvmcluster-using-rhacm_{context}"] |
| 7 | += Deleting an LVMCluster CR by using {rh-rhacm} |
| 8 | + |
| 9 | +If you have installed {lvms} by using {rh-rhacm-first}, you can delete an `LVMCluster` CR by using {rh-rhacm}. |
| 10 | + |
| 11 | +.Prerequisites |
| 12 | + |
| 13 | +* You have access to the {rh-rhacm} cluster as a user with `cluster-admin` permissions. |
| 14 | +* You have deleted the persistent volume claims (PVCs), volume snapshots, and volume clones provisioned by {lvms}. You have also deleted the applications that are using these resources. |
| 15 | +
|
| 16 | +.Procedure |
| 17 | + |
| 18 | +. Log in to the {rh-rhacm} CLI using your {product-title} credentials. |
| 19 | +. Delete the `ConfigurationPolicy` CR YAML file that was created for the `LVMCluster` CR: |
| 20 | ++ |
| 21 | +[source,terminal] |
| 22 | +---- |
| 23 | +$ oc delete -f <file_name> -n <cluster_namespace> <1> |
| 24 | +---- |
| 25 | +<1> Namespace of the {product-title} cluster on which {lvms} is installed. |
| 26 | + |
| 27 | +. Create a `Policy` CR YAML file to delete the `LVMCluster` CR: |
| 28 | ++ |
| 29 | +.Example `Policy` CR to delete the `LVMCluster` CR |
| 30 | +[source,yaml] |
| 31 | +---- |
| 32 | +apiVersion: policy.open-cluster-management.io/v1 |
| 33 | +kind: Policy |
| 34 | +metadata: |
| 35 | + name: policy-lvmcluster-delete |
| 36 | + annotations: |
| 37 | + policy.open-cluster-management.io/standards: NIST SP 800-53 |
| 38 | + policy.open-cluster-management.io/categories: CM Configuration Management |
| 39 | + policy.open-cluster-management.io/controls: CM-2 Baseline Configuration |
| 40 | +spec: |
| 41 | + remediationAction: enforce |
| 42 | + disabled: false |
| 43 | + policy-templates: |
| 44 | + - objectDefinition: |
| 45 | + apiVersion: policy.open-cluster-management.io/v1 |
| 46 | + kind: ConfigurationPolicy |
| 47 | + metadata: |
| 48 | + name: policy-lvmcluster-removal |
| 49 | + spec: |
| 50 | + remediationAction: enforce <1> |
| 51 | + severity: low |
| 52 | + object-templates: |
| 53 | + - complianceType: mustnothave |
| 54 | + objectDefinition: |
| 55 | + kind: LVMCluster |
| 56 | + apiVersion: lvm.topolvm.io/v1alpha1 |
| 57 | + metadata: |
| 58 | + name: my-lvmcluster |
| 59 | + namespace: openshift-storage <2> |
| 60 | +--- |
| 61 | +apiVersion: policy.open-cluster-management.io/v1 |
| 62 | +kind: PlacementBinding |
| 63 | +metadata: |
| 64 | + name: binding-policy-lvmcluster-delete |
| 65 | +placementRef: |
| 66 | + apiGroup: apps.open-cluster-management.io |
| 67 | + kind: PlacementRule |
| 68 | + name: placement-policy-lvmcluster-delete |
| 69 | +subjects: |
| 70 | + - apiGroup: policy.open-cluster-management.io |
| 71 | + kind: Policy |
| 72 | + name: policy-lvmcluster-delete |
| 73 | +--- |
| 74 | +apiVersion: apps.open-cluster-management.io/v1 |
| 75 | +kind: PlacementRule |
| 76 | +metadata: |
| 77 | + name: placement-policy-lvmcluster-delete |
| 78 | +spec: |
| 79 | + clusterConditions: |
| 80 | + - status: "True" |
| 81 | + type: ManagedClusterConditionAvailable |
| 82 | + clusterSelector: <3> |
| 83 | + matchExpressions: |
| 84 | + - key: mykey |
| 85 | + operator: In |
| 86 | + values: |
| 87 | + - myvalue |
| 88 | +---- |
| 89 | +<1> The `spec.remediationAction` in `policy-template` is overridden by the preceding parameter value for `spec.remediationAction`. |
| 90 | +<2> This `namespace` field must have the `openshift-storage` value. |
| 91 | +<3> Configure the requirements to select the clusters. {lvms} is uninstalled on the clusters that match the selection criteria. |
| 92 | + |
| 93 | +. Create the `Policy` CR by running the following command: |
| 94 | ++ |
| 95 | +[source,terminal] |
| 96 | +---- |
| 97 | +$ oc create -f <file_name> -n <namespace> |
| 98 | +---- |
| 99 | + |
| 100 | +. Create a `Policy` CR YAML file to check if the `LVMCluster` CR has been deleted: |
| 101 | ++ |
| 102 | +.Example `Policy` CR to check if the `LVMCluster` CR has been deleted |
| 103 | +[source,yaml] |
| 104 | +---- |
| 105 | +apiVersion: policy.open-cluster-management.io/v1 |
| 106 | +kind: Policy |
| 107 | +metadata: |
| 108 | + name: policy-lvmcluster-inform |
| 109 | + annotations: |
| 110 | + policy.open-cluster-management.io/standards: NIST SP 800-53 |
| 111 | + policy.open-cluster-management.io/categories: CM Configuration Management |
| 112 | + policy.open-cluster-management.io/controls: CM-2 Baseline Configuration |
| 113 | +spec: |
| 114 | + remediationAction: inform |
| 115 | + disabled: false |
| 116 | + policy-templates: |
| 117 | + - objectDefinition: |
| 118 | + apiVersion: policy.open-cluster-management.io/v1 |
| 119 | + kind: ConfigurationPolicy |
| 120 | + metadata: |
| 121 | + name: policy-lvmcluster-removal-inform |
| 122 | + spec: |
| 123 | + remediationAction: inform <1> |
| 124 | + severity: low |
| 125 | + object-templates: |
| 126 | + - complianceType: mustnothave |
| 127 | + objectDefinition: |
| 128 | + kind: LVMCluster |
| 129 | + apiVersion: lvm.topolvm.io/v1alpha1 |
| 130 | + metadata: |
| 131 | + name: my-lvmcluster |
| 132 | + namespace: openshift-storage <2> |
| 133 | +--- |
| 134 | +apiVersion: policy.open-cluster-management.io/v1 |
| 135 | +kind: PlacementBinding |
| 136 | +metadata: |
| 137 | + name: binding-policy-lvmcluster-check |
| 138 | +placementRef: |
| 139 | + apiGroup: apps.open-cluster-management.io |
| 140 | + kind: PlacementRule |
| 141 | + name: placement-policy-lvmcluster-check |
| 142 | +subjects: |
| 143 | + - apiGroup: policy.open-cluster-management.io |
| 144 | + kind: Policy |
| 145 | + name: policy-lvmcluster-inform |
| 146 | +--- |
| 147 | +apiVersion: apps.open-cluster-management.io/v1 |
| 148 | +kind: PlacementRule |
| 149 | +metadata: |
| 150 | + name: placement-policy-lvmcluster-check |
| 151 | +spec: |
| 152 | + clusterConditions: |
| 153 | + - status: "True" |
| 154 | + type: ManagedClusterConditionAvailable |
| 155 | + clusterSelector: |
| 156 | + matchExpressions: |
| 157 | + - key: mykey |
| 158 | + operator: In |
| 159 | + values: |
| 160 | + - myvalue |
| 161 | +---- |
| 162 | +<1> The `policy-template` `spec.remediationAction` is overridden by the preceding parameter value for `spec.remediationAction`. |
| 163 | +<2> The `namespace` field must have the `openshift-storage` value. |
| 164 | + |
| 165 | +. Create the `Policy` CR by running the following command: |
| 166 | ++ |
| 167 | +[source,terminal] |
| 168 | +---- |
| 169 | +$ oc create -f <file_name> -n <namespace> |
| 170 | +---- |
| 171 | + |
| 172 | +.Verification |
| 173 | + |
| 174 | +* Check the status of the `Policy` CRs by running the following command: |
| 175 | ++ |
| 176 | +[source,terminal] |
| 177 | +---- |
| 178 | +$ oc get policy -n <namespace> |
| 179 | +---- |
| 180 | ++ |
| 181 | +.Example output |
| 182 | +[source,terminal] |
| 183 | +---- |
| 184 | +NAME REMEDIATION ACTION COMPLIANCE STATE AGE |
| 185 | +policy-lvmcluster-delete enforce Compliant 15m |
| 186 | +policy-lvmcluster-inform inform Compliant 15m |
| 187 | +---- |
| 188 | ++ |
| 189 | +[IMPORTANT] |
| 190 | +==== |
| 191 | +The `Policy` CRs must be in `Compliant` state. |
| 192 | +==== |
0 commit comments