2.11. 백업 및 복원을 위한 허브 클러스터 구성
GitOps ZTP를 사용하여 BareMetalHost
리소스를 백업하도록 정책 세트를 구성할 수 있습니다. 이를 통해 실패한 허브 클러스터에서 데이터를 복구하고 RHACM(Red Hat Advanced Cluster Management)을 사용하여 대체 클러스터를 배포할 수 있습니다.
사전 요구 사항
-
OpenShift CLI(
oc
)가 설치되어 있습니다. -
cluster-admin
권한이 있는 사용자로 로그인했습니다.
프로세스
infraenvs.agent-install.openshift.io
레이블이 있는 모든BareMetalHost
리소스에cluster.open-cluster-management.io/backup=cluster-activation
라벨을 추가하는 정책을 생성합니다. 정책을BareMetalHostBackupPolicy.yaml
로 저장합니다.다음 예제에서는
infraenvs.agent-install.openshift.io
라벨이 있는 모든BareMetalHost
리소스에cluster.open-cluster-management.io/backup
라벨을 추가합니다.정책 예
apiVersion: policy.open-cluster-management.io/v1 kind: Policy metadata: name: bmh-cluster-activation-label annotations: policy.open-cluster-management.io/description: Policy used to add the cluster.open-cluster-management.io/backup=cluster-activation label to all BareMetalHost resources spec: disabled: false policy-templates: - objectDefinition: apiVersion: policy.open-cluster-management.io/v1 kind: ConfigurationPolicy metadata: name: set-bmh-backup-label spec: object-templates-raw: | {{- /* Set cluster-activation label on all BMH resources */ -}} {{- $infra_label := "infraenvs.agent-install.openshift.io" }} {{- range $bmh := (lookup "metal3.io/v1alpha1" "BareMetalHost" "" "" $infra_label).items }} - complianceType: musthave objectDefinition: kind: BareMetalHost apiVersion: metal3.io/v1alpha1 metadata: name: {{ $bmh.metadata.name }} namespace: {{ $bmh.metadata.namespace }} labels: cluster.open-cluster-management.io/backup: cluster-activation 1 {{- end }} remediationAction: enforce severity: high --- apiVersion: cluster.open-cluster-management.io/v1beta1 kind: Placement metadata: name: bmh-cluster-activation-label-pr spec: predicates: - requiredClusterSelector: labelSelector: matchExpressions: - key: name operator: In values: - local-cluster --- apiVersion: policy.open-cluster-management.io/v1 kind: PlacementBinding metadata: name: bmh-cluster-activation-label-binding placementRef: name: bmh-cluster-activation-label-pr apiGroup: cluster.open-cluster-management.io kind: Placement subjects: - name: bmh-cluster-activation-label apiGroup: policy.open-cluster-management.io kind: Policy --- apiVersion: cluster.open-cluster-management.io/v1beta2 kind: ManagedClusterSetBinding metadata: name: default namespace: default spec: clusterSet: default
- 1
cluster.open-cluster-management.io/backup: cluster-activation
라벨을BareMetalHost
리소스에 적용하는 경우 RHACM 클러스터는 해당 리소스를 백업합니다. 허브 활성화 리소스를 복원할 때 활성 클러스터를 사용할 수 없게 되면BareMetalHost
리소스를 복원할 수 있습니다.
다음 명령을 실행하여 정책을 적용합니다.
$ oc apply -f BareMetalHostBackupPolicy.yaml
검증
다음 명령을 실행하여
infraenvs.agent-install.openshift.io
레이블을 사용하여 모든BareMetalHost
리소스를 찾습니다.$ oc get BareMetalHost -A -l infraenvs.agent-install.openshift.io
출력 예
NAMESPACE NAME STATE CONSUMER ONLINE ERROR AGE baremetal-ns baremetal-name false 50s
다음 명령을 실행하여 정책이 해당 모든 리소스에
cluster.open-cluster-management.io/backup=cluster-activation
라벨을 적용했는지 확인합니다.$ oc get BareMetalHost -A -l infraenvs.agent-install.openshift.io,cluster.open-cluster-management.io/backup=cluster-activation
출력 예
NAMESPACE NAME STATE CONSUMER ONLINE ERROR AGE baremetal-ns baremetal-name false 50s
출력에는 이전 단계와 동일한 목록이 표시되어야 합니다. 이 목록은
infraenvs.agent-install.openshift.io
레이블이 있는 모든BareMetalHost
리소스를 나열했습니다. 이렇게 하면infraenvs.agent-install.openshift.io
레이블이 있는 모든BareMetalHost
리소스에cluster.open-cluster-management.io/backup: cluster-activation
레이블이 있는지 확인합니다.다음 예제는
infraenvs.agent-install.openshift.io
레이블이 있는BareMetalHost
리소스를 보여줍니다. 리소스에는 생성한 정책에 의해 추가된cluster.open-cluster-management.io/backup: cluster-activation
레이블이 있어야 합니다.apiVersion: metal3.io/v1alpha1 kind: BareMetalHost metadata: labels: cluster.open-cluster-management.io/backup: cluster-activation infraenvs.agent-install.openshift.io: value name: baremetal-name namespace: baremetal-ns
이제 Red Hat Advanced Cluster Management를 사용하여 관리형 클러스터를 복원할 수 있습니다.
BareMetalHosts
리소스를 클러스터 활성화 데이터 복원의 일부로 복원하는 경우 BareMetalHosts
상태를 복원해야 합니다. 다음 RHACM Restore
리소스 예제에서는 BareMetalHosts
를 포함한 활성화 리소스를 복원하고 BareMetalHosts
리소스의 상태도 복원합니다.
apiVersion: cluster.open-cluster-management.io/v1beta1 kind: Restore metadata: name: restore-acm-bmh namespace: open-cluster-management-backup spec: cleanupBeforeRestore: CleanupRestored veleroManagedClustersBackupName: latest 1 veleroCredentialsBackupName: latest veleroResourcesBackupName: latest restoreStatus: includedResources: - BareMetalHosts2