2.11. 백업 및 복원을 위한 허브 클러스터 구성
GitOps ZTP를 사용하면 BareMetalHost 리소스를 백업하기 위한 정책 세트를 구성할 수 있습니다. 이를 통해 실패한 허브 클러스터에서 데이터를 복구하고 Red Hat Advanced Cluster Management(RHACM)를 사용하여 대체 클러스터를 배포할 수 있습니다.
사전 요구 사항
-
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-activation1 {{- 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리소스를 보여줍니다. 리소스에는 1단계에서 만든 정책에 의해 추가된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 복원 리소스 예제는 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
veleroCredentialsBackupName: latest
veleroResourcesBackupName: latest
restoreStatus:
includedResources:
- BareMetalHosts