2.11. 백업 및 복원을 위한 허브 클러스터 구성


GitOps ZTP를 사용하여 BareMetalHost 리소스를 백업하도록 정책 세트를 구성할 수 있습니다. 이를 통해 실패한 허브 클러스터에서 데이터를 복구하고 RHACM(Red Hat Advanced Cluster Management)을 사용하여 대체 클러스터를 배포할 수 있습니다.

사전 요구 사항

  • OpenShift CLI(oc)가 설치되어 있습니다.
  • cluster-admin 권한이 있는 사용자로 로그인했습니다.

프로세스

  1. 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 리소스를 복원할 수 있습니다.
  2. 다음 명령을 실행하여 정책을 적용합니다.

    $ oc apply -f BareMetalHostBackupPolicy.yaml

검증

  1. 다음 명령을 실행하여 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

  2. 다음 명령을 실행하여 정책이 해당 모든 리소스에 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
1
veleroManagedClustersBackupName: latest 를 설정하여 활성화 리소스를 복원합니다.
2
BareMetalHosts 리소스의 상태를 복원합니다.
Red Hat logoGithubRedditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

© 2024 Red Hat, Inc.