애플리케이션 백업 및 복원

Red Hat OpenShift Service on AWS 4

애플리케이션 데이터 백업 및 복원

Red Hat OpenShift Documentation Team

초록

이 문서에서는 애플리케이션 백업에 대한 정보를 제공합니다.

1장. 애플리케이션 백업

ROSA(Red Hat OpenShift Service on AWS) 클러스터에서 OADP(Data Protection)를 사용하여 애플리케이션 데이터를 백업 및 복원할 수 있습니다. OADP를 설치하기 전에 AWS API를 사용할 수 있도록 OADP의 역할 및 정책 자격 증명을 설정해야 합니다.

이는 두 단계의 프로세스입니다.

  1. AWS 인증 정보를 준비합니다.
  2. OADP Operator를 설치하고 IAM 역할을 제공합니다.

1.1. AWS 인증 정보 준비

AWS 계정은 OADP 설치를 수락할 준비가 되어 있어야 합니다.

절차

  1. 다음 명령을 실행하여 다음 환경 변수를 생성합니다.

    참고

    ROSA 클러스터와 일치하도록 클러스터 이름을 변경하고 관리자로 클러스터에 로그인했는지 확인합니다. 계속하기 전에 모든 필드가 올바르게 출력되었는지 확인합니다.

    $ export CLUSTER_NAME=my-cluster 1
    export ROSA_CLUSTER_ID=$(rosa describe cluster -c ${CLUSTER_NAME} --output json | jq -r .id)
    export REGION=$(rosa describe cluster -c ${CLUSTER_NAME} --output json | jq -r .region.id)
    export OIDC_ENDPOINT=$(oc get authentication.config.openshift.io cluster -o jsonpath='{.spec.serviceAccountIssuer}' | sed 's|^https://||')
    export AWS_ACCOUNT_ID=$(aws sts get-caller-identity --query Account --output text)
    export CLUSTER_VERSION=$(rosa describe cluster -c ${CLUSTER_NAME} -o json | jq -r .version.raw_id | cut -f -2 -d '.')
    export ROLE_NAME="${CLUSTER_NAME}-openshift-oadp-aws-cloud-credentials"
    export SCRATCH="/tmp/${CLUSTER_NAME}/oadp"
    mkdir -p ${SCRATCH}
    echo "Cluster ID: ${ROSA_CLUSTER_ID}, Region: ${REGION}, OIDC Endpoint:
    ${OIDC_ENDPOINT}, AWS Account ID: ${AWS_ACCOUNT_ID}"
    1
    my-cluster 를 ROSA 클러스터 이름으로 교체합니다.
  2. AWS 계정에서 S3에 대한 액세스를 허용하는 IAM 정책을 생성합니다.

    1. 다음 명령을 실행하여 정책이 존재하는지 확인합니다.

      $ POLICY_ARN=$(aws iam list-policies --query "Policies[?PolicyName=='RosaOadpVer1'].{ARN:Arn}" --output text) 1
      1
      RosaOadp 를 정책 이름으로 교체합니다.
    2. 다음 명령을 사용하여 정책 JSON 파일을 생성한 다음 ROSA에서 정책을 생성합니다.

      참고

      정책 ARN을 찾을 수 없는 경우 명령에서 정책을 생성합니다. 정책 ARN이 이미 존재하는 경우 if 문이 의도적으로 정책 생성을 건너뜁니다.

      $ if [[ -z "${POLICY_ARN}" ]]; then
      cat << EOF > ${SCRATCH}/policy.json 1
      {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": [
            "s3:CreateBucket",
            "s3:DeleteBucket",
            "s3:PutBucketTagging",
            "s3:GetBucketTagging",
            "s3:PutEncryptionConfiguration",
            "s3:GetEncryptionConfiguration",
            "s3:PutLifecycleConfiguration",
            "s3:GetLifecycleConfiguration",
            "s3:GetBucketLocation",
            "s3:ListBucket",
            "s3:GetObject",
            "s3:PutObject",
            "s3:DeleteObject",
            "s3:ListBucketMultipartUploads",
            "s3:AbortMultipartUpload",
            "s3:ListMultipartUploadParts",
            "ec2:DescribeSnapshots",
            "ec2:DescribeVolumes",
            "ec2:DescribeVolumeAttribute",
            "ec2:DescribeVolumesModifications",
            "ec2:DescribeVolumeStatus",
            "ec2:CreateTags",
            "ec2:CreateVolume",
            "ec2:CreateSnapshot",
            "ec2:DeleteSnapshot"
          ],
          "Resource": "*"
        }
       ]}
      EOF
      
      POLICY_ARN=$(aws iam create-policy --policy-name "RosaOadpVer1" \
      --policy-document file:///${SCRATCH}/policy.json --query Policy.Arn \
      --tags Key=rosa_openshift_version,Value=${CLUSTER_VERSION} Key=rosa_role_prefix,Value=ManagedOpenShift Key=operator_namespace,Value=openshift-oadp Key=operator_name,Value=openshift-oadp \
      --output text)
      fi
      1
      SCRATCH 는 환경 변수에 대해 생성된 임시 디렉터리의 이름입니다.
    3. 다음 명령을 실행하여 정책 ARN을 확인합니다.

      $ echo ${POLICY_ARN}
  3. 클러스터에 대한 IAM 역할 신뢰 정책을 생성합니다.

    1. 다음 명령을 실행하여 신뢰 정책 파일을 생성합니다.

      $ cat <<EOF > ${SCRATCH}/trust-policy.json
      {
          "Version": "2012-10-17",
          "Statement": [{
            "Effect": "Allow",
            "Principal": {
              "Federated": "arn:aws:iam::${AWS_ACCOUNT_ID}:oidc-provider/${OIDC_ENDPOINT}"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
              "StringEquals": {
                "${OIDC_ENDPOINT}:sub": [
                  "system:serviceaccount:openshift-adp:openshift-adp-controller-manager",
                  "system:serviceaccount:openshift-adp:velero"]
              }
            }
          }]
      }
      EOF
    2. 다음 명령을 실행하여 역할을 생성합니다.

      $ ROLE_ARN=$(aws iam create-role --role-name \
        "${ROLE_NAME}" \
        --assume-role-policy-document file://${SCRATCH}/trust-policy.json \
        --tags Key=rosa_cluster_id,Value=${ROSA_CLUSTER_ID}
      Key=rosa_openshift_version,Value=${CLUSTER_VERSION}
      Key=rosa_role_prefix,Value=ManagedOpenShift
      Key=operator_namespace,Value=openshift-adp
      Key=operator_name,Value=openshift-oadp \
         --query Role.Arn --output text)
    3. 다음 명령을 실행하여 역할 ARN을 확인합니다.

      $ echo ${ROLE_ARN}
  4. 다음 명령을 실행하여 IAM 역할에 IAM 정책을 연결합니다.

    $ aws iam attach-role-policy --role-name "${ROLE_NAME}" \
      --policy-arn ${POLICY_ARN}

다음 단계

  • OADP Operator 설치를 계속하고 IAM 역할을 제공합니다.

1.2. OADP Operator 설치 및 IAM 역할 제공

AWS STS(AWS Security Token Service)는 IAM 또는 페더레이션 사용자를 위한 단기 인증 정보를 제공하는 글로벌 웹 서비스입니다. STS를 사용하는 ROSA(Red Hat OpenShift Service on AWS)는 ROSA 클러스터에 권장되는 인증 정보 모드입니다. 이 문서에서는 AWS STS를 사용하여ROSA(ROSA)에 OADP(OpenShift API for Data Protection)를 설치하는 방법을 설명합니다.

중요

Restic 및 Kopia는 AWS STS 환경의 ROSA의 OADP에서 지원되지 않습니다. Restic/Kopia 노드 에이전트가 비활성화되어 있는지 확인합니다. 볼륨 백업의 경우 AWS STS를 사용하여 ROSA의 OADP는 기본 스냅샷 및 CSI 스냅샷만 지원합니다. 자세한 내용은 알려진 문제를 참조하십시오.

중요

STS 인증을 사용하는 Amazon ROSA 클러스터에서는 다른 AWS 리전에서 백업 데이터를 복원할 수 없습니다.

Data Mover 기능은 현재 ROSA 클러스터에서 지원되지 않습니다. 데이터 이동을 위해 기본 AWS S3 툴을 사용할 수 있습니다.

사전 요구 사항

  • 필요한 액세스 및 토큰이 있는 클러스터입니다. 자세한 내용은 "AWS 인증 정보 준비"의 절차를 참조하십시오. 백업 및 복원에 두 개의 다른 클러스터를 사용하려면 각 클러스터에 대해 ROLE_ARN 을 포함한 AWS 인증 정보를 준비해야 합니다.

절차

  1. 다음 명령을 입력하여 AWS 토큰 파일에서 OpenShift 시크릿을 생성합니다.

    1. 자격 증명 파일을 생성합니다.

      $ cat <<EOF > ${SCRATCH}/credentials
      [default]
      role_arn = ${ROLE_ARN}
      web_identity_token_file = /var/run/secrets/openshift/serviceaccount/token
      EOF
    2. OADP의 네임스페이스를 생성합니다.

      $ oc create namespace openshift-adp
    3. OpenShift 시크릿을 생성합니다.

      $ oc -n openshift-adp create secret generic cloud-credentials \
        --from-file=${SCRATCH}/credentials
      참고

      AWS 버전 4.15 이상에서 OADP Operator는 OLM(Operator Lifecycle Manager) 및 CCO(Cloud Credentials Operator)를 통해 새로운 표준화된 STS 워크플로를 지원합니다. 이 워크플로에서는 시크릿을 생성할 필요가 없으며 AWS 웹 콘솔에서 Red Hat OpenShift Service를 통해 OLM 관리 Operator를 설치하는 동안 ARN 역할을 제공해야 합니다. 위의 시크릿은 CCO를 통해 자동으로 생성됩니다.

  2. OADP Operator를 설치합니다.

    1. AWS 웹 콘솔의 Red Hat OpenShift Service에서 Operator OperatorHub로 이동합니다.
    2. OADP Operator를 검색한 다음 설치를 클릭합니다.
  3. AWS 인증 정보를 사용하여 AWS 클라우드 스토리지를 생성합니다.

    $ cat << EOF | oc create -f -
    apiVersion: oadp.openshift.io/v1alpha1
    kind: CloudStorage
    metadata:
      name: ${CLUSTER_NAME}-oadp
      namespace: openshift-adp
    spec:
      creationSecret:
        key: credentials
        name: cloud-credentials
      enableSharedConfig: true
      name: ${CLUSTER_NAME}-oadp
      provider: aws
      region: $REGION
    EOF
  4. 백업 및 볼륨 스냅샷이 저장되는 스토리지에 대한 연결을 구성하는 데 사용되는 DataProtectionApplication 리소스를 만듭니다.

    $ cat << EOF | oc create -f -
    apiVersion: oadp.openshift.io/v1alpha1
    kind: DataProtectionApplication
    metadata:
      name: ${CLUSTER_NAME}-dpa
      namespace: openshift-adp
    spec:
      backupLocations:
      - bucket:
          cloudStorageRef:
            name: ${CLUSTER_NAME}-oadp
          credential:
            key: credentials
            name: cloud-credentials
          prefix: velero
          default: true
          config:
            region: ${REGION}
      configuration:
        velero:
          defaultPlugins:
          - openshift
          - aws
        nodeAgent: 1
          enable: false
          uploaderType: restic
      snapshotLocations:
        - velero:
            config:
              credentialsFile: /tmp/credentials/openshift-adp/cloud-credentials-credentials 2
              enableSharedConfig: "true" 3
              profile: default 4
              region: ${REGION} 5
            provider: aws
    EOF
    1
    아래의 첫 번째 노트를 참조하십시오.
    2
    credentialsFile 필드는 Pod에 버킷 인증 정보의 마운트된 위치입니다.
    3
    enableSharedConfig 필드를 사용하면 snapshotLocations 에서 버킷에 대해 정의된 인증 정보를 공유하거나 재사용할 수 있습니다.
    4
    AWS 인증 정보 파일에 설정된 프로필 이름을 사용합니다.
    5
    리전을 AWS 리전 으로 지정합니다. 이는 클러스터 리전과 동일해야 합니다.

    이제 OADP 설명서에 설명된 대로 OpenShift 애플리케이션을 백업 및 복원할 준비가 되었습니다.

참고

OADP는 ROSA 환경에서 Restic을 지원하지 않기 때문에 resticenable 매개 변수는 이 구성에서 false 로 설정됩니다.

OADP 1.2를 사용하는 경우 이 구성을 교체합니다.

nodeAgent:
  enable: false
  uploaderType: restic

다음을 수행합니다.

restic:
  enable: false
참고

백업 및 복원을 위해 두 개의 다른 클러스터를 사용하려면 cloudstorage CR 및 OADP DataProtectionApplication 구성 둘 다에 동일한 AWS S3 스토리지 이름이 있어야 합니다.

추가 리소스

1.3. 확인된 문제

1.4. 추가 리소스

법적 공지

Copyright © 2024 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.