Skip to content

Commit 129271b

Browse files
committed
TELCODOCS-1975 - ZTP Configuring the hub cluster for backup and restore
1 parent 4f3e07e commit 129271b

File tree

2 files changed

+188
-0
lines changed

2 files changed

+188
-0
lines changed

edge_computing/ztp-preparing-the-hub-cluster.adoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,14 @@ include::snippets/pgt-deprecation-notice.adoc[]
6262
* xref:../edge_computing/policygenerator_for_ztp/ztp-configuring-managed-clusters-policygenerator.adoc#ztp-comparing-pgt-and-rhacm-pg-patching-strategies_ztp-configuring-managed-clusters-policygenerator[Comparing {rh-rhacm} PolicyGenerator and PolicyGenTemplate resource patching]
6363
6464
include::modules/ztp-preparing-the-ztp-git-repository-ver-ind.adoc[leveloffset=+1]
65+
66+
include::modules/ztp-configuring-the-hub-cluster-for-backup-and-restore.adoc[leveloffset=+1]
67+
68+
[role="_additional-resources"]
69+
.Additional resources
70+
71+
* link:https://docs.redhat.com/en/documentation/red_hat_advanced_cluster_management_for_kubernetes/latest/html/business_continuity/business-cont-overview#managed-cluster-activation-data[Restoring managed cluster activation data]
72+
73+
* link:https://docs.redhat.com/en/documentation/red_hat_advanced_cluster_management_for_kubernetes/latest/html/business_continuity/business-cont-overview#active-passive-config[Active-passive configuration]
74+
75+
* link:https://docs.redhat.com/en/documentation/red_hat_advanced_cluster_management_for_kubernetes/latest/html/business_continuity/business-cont-overview#restore-activation-resources[Restoring activation resources]
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * scalability_and_performance/ztp_far_edge/ztp-preparing-the-hub-cluster.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="ztp-configuring-the-hub-cluster-for-backup-and-restore_{context}"]
7+
= Configuring the hub cluster for backup and restore
8+
9+
You can use {ztp} to configure a set of policies to backup `BareMetalHost` resources.
10+
This allows you to recover data from a failed hub cluster and deploy a replacement cluster using {rh-rhacm-first}.
11+
12+
.Prerequisites
13+
14+
* You have installed the OpenShift CLI (`oc`).
15+
16+
* You have logged in as a user with `cluster-admin` privileges.
17+
18+
.Procedure
19+
20+
. Create a policy to add the `cluster.open-cluster-management.io/backup=cluster-activation` label to all `BareMetalHost` resources that have the `infraenvs.agent-install.openshift.io` label.
21+
Save the policy as `BareMetalHostBackupPolicy.yaml`.
22+
+
23+
The following example adds the `cluster.open-cluster-management.io/backup` label to all `BareMetalHost` resources that have the `infraenvs.agent-install.openshift.io` label:
24+
+
25+
.Example Policy
26+
[source,yaml]
27+
----
28+
apiVersion: policy.open-cluster-management.io/v1
29+
kind: Policy
30+
metadata:
31+
name: bmh-cluster-activation-label
32+
annotations:
33+
policy.open-cluster-management.io/description: Policy used to add the cluster.open-cluster-management.io/backup=cluster-activation label to all BareMetalHost resources
34+
spec:
35+
disabled: false
36+
policy-templates:
37+
- objectDefinition:
38+
apiVersion: policy.open-cluster-management.io/v1
39+
kind: ConfigurationPolicy
40+
metadata:
41+
name: set-bmh-backup-label
42+
spec:
43+
object-templates-raw: |
44+
{{- /* Set cluster-activation label on all BMH resources */ -}}
45+
{{- $infra_label := "infraenvs.agent-install.openshift.io" }}
46+
{{- range $bmh := (lookup "metal3.io/v1alpha1" "BareMetalHost" "" "" $infra_label).items }}
47+
- complianceType: musthave
48+
objectDefinition:
49+
kind: BareMetalHost
50+
apiVersion: metal3.io/v1alpha1
51+
metadata:
52+
name: {{ $bmh.metadata.name }}
53+
namespace: {{ $bmh.metadata.namespace }}
54+
labels:
55+
cluster.open-cluster-management.io/backup: cluster-activation <1>
56+
{{- end }}
57+
remediationAction: enforce
58+
severity: high
59+
---
60+
apiVersion: cluster.open-cluster-management.io/v1beta1
61+
kind: Placement
62+
metadata:
63+
name: bmh-cluster-activation-label-pr
64+
spec:
65+
predicates:
66+
- requiredClusterSelector:
67+
labelSelector:
68+
matchExpressions:
69+
- key: name
70+
operator: In
71+
values:
72+
- local-cluster
73+
---
74+
apiVersion: policy.open-cluster-management.io/v1
75+
kind: PlacementBinding
76+
metadata:
77+
name: bmh-cluster-activation-label-binding
78+
placementRef:
79+
name: bmh-cluster-activation-label-pr
80+
apiGroup: cluster.open-cluster-management.io
81+
kind: Placement
82+
subjects:
83+
- name: bmh-cluster-activation-label
84+
apiGroup: policy.open-cluster-management.io
85+
kind: Policy
86+
---
87+
apiVersion: cluster.open-cluster-management.io/v1beta2
88+
kind: ManagedClusterSetBinding
89+
metadata:
90+
name: default
91+
namespace: default
92+
spec:
93+
clusterSet: default
94+
----
95+
<1> If you apply the `cluster.open-cluster-management.io/backup: cluster-activation` label to `BareMetalHost` resources, the {rh-rhacm} cluster backs up those resources.
96+
You can restore the `BareMetalHost` resources if the active cluster becomes unavailable, when restoring the hub activation resources.
97+
98+
. Apply the policy by running the following command:
99+
+
100+
[source,terminal]
101+
----
102+
$ oc apply -f BareMetalHostBackupPolicy.yaml
103+
----
104+
105+
.Verification
106+
107+
. Find all `BareMetalHost` resources with the label `infraenvs.agent-install.openshift.io` by running the following command:
108+
+
109+
[source,terminal]
110+
----
111+
$ oc get BareMetalHost -A -l infraenvs.agent-install.openshift.io
112+
----
113+
+
114+
.Example output
115+
[source,yaml]
116+
----
117+
NAMESPACE NAME STATE CONSUMER ONLINE ERROR AGE
118+
baremetal-ns baremetal-name false 50s
119+
----
120+
121+
. Verify that the policy has applied the label `cluster.open-cluster-management.io/backup=cluster-activation` to all these resources, by runing the following command:
122+
+
123+
[source,terminal]
124+
----
125+
$ oc get BareMetalHost -A -l infraenvs.agent-install.openshift.io,cluster.open-cluster-management.io/backup=cluster-activation
126+
----
127+
+
128+
.Example output
129+
[source,yaml]
130+
----
131+
NAMESPACE NAME STATE CONSUMER ONLINE ERROR AGE
132+
baremetal-ns baremetal-name false 50s
133+
----
134+
+
135+
The output must show the same list as in the previous step, which listed all `BareMetalHost` resources with the label `infraenvs.agent-install.openshift.io`.
136+
This confirms that that all the `BareMetalHost` resources with the `infraenvs.agent-install.openshift.io` label also have the `cluster.open-cluster-management.io/backup: cluster-activation` label.
137+
+
138+
The following example shows a `BareMetalHost` resource with the `infraenvs.agent-install.openshift.io` label.
139+
The resource must also have the `cluster.open-cluster-management.io/backup: cluster-activation` label, which was added by the policy created in step 1.
140+
+
141+
[source,yaml]
142+
----
143+
apiVersion: metal3.io/v1alpha1
144+
kind: BareMetalHost
145+
metadata:
146+
labels:
147+
cluster.open-cluster-management.io/backup: cluster-activation
148+
infraenvs.agent-install.openshift.io: value
149+
name: baremetal-name
150+
namespace: baremetal-ns
151+
----
152+
153+
You can now use {rh-rhacm-title} to restore a managed cluster.
154+
155+
[IMPORTANT]
156+
====
157+
When you restore `BareMetalHosts` resources as part of restoring the cluster activation data, you must restore the `BareMetalHosts` status.
158+
The following {rh-rhacm} `Restore` resource example restores activation resources, including `BareMetalHosts`, and also restores the status for the `BareMetalHosts` resources:
159+
[source,yaml]
160+
----
161+
apiVersion: cluster.open-cluster-management.io/v1beta1
162+
kind: Restore
163+
metadata:
164+
name: restore-acm-bmh
165+
namespace: open-cluster-management-backup
166+
spec:
167+
cleanupBeforeRestore: CleanupRestored
168+
veleroManagedClustersBackupName: latest <1>
169+
veleroCredentialsBackupName: latest
170+
veleroResourcesBackupName: latest
171+
restoreStatus:
172+
includedResources:
173+
- BareMetalHosts<2>
174+
----
175+
====
176+
<1> Set `veleroManagedClustersBackupName: latest` to restore activation resources.
177+
<2> Restores the status for `BareMetalHosts` resources.

0 commit comments

Comments
 (0)