Kubernetes Cluster Backup with Velero

송형근·2024년 1월 23일
1

K8S작업모음

목록 보기
1/2
post-thumbnail

Velero Cluster Backup with Velero and S3 or EFS


사전 준비


  • Velero Image
  • Velero Install file
  • S3 사용
    • Velero-plugin-for-aws Image
    • S3 Bucket
    • AWS User Credential ( S3 사용 권한 필수 )
    • kube2iam ( arn 사용할 경우 )
  • EFS 사용
    • Velero-plugin-for-aws Image
    • EFS
    • Minio
    • Credential ( EFS 사용 권한 )

Velero 설치


tar zxf velero-v1.12.2-linux-amd64.tar.gz
mv velero-v1.12.2-linux-amd64/velero /usr/local/bin/

Velero AWS Plugin 설치


# S3 + Credential
velero install \
   --provider aws \
   --plugins docker.io/velero/velero-plugin-for-aws:v1.8.2 \
   --bucket ps-lucas-velero-backup-test \
   --backup-location-config region=ap-northeast-2 \
   --snapshot-location-config region=ap-northeast-2 \
   --secret-file velero-s3-test \ # IAM과 Key가 포함된 credential 파일 명

# S3 + ARN 사용
velero install \
   --provider aws \
   --plugins docker.io/velero/velero-plugin-for-aws:v1.8.2 \
   --bucket ps-lucas-velero-backup-test \
   --backup-location-config region=ap-northeast-2 \
   --snapshot-location-config region=ap-northeast-2 \
   --pod-annotations iam.amazonaws.com/role=arn:aws:iam::{ARN} \
   --no-secret

# EFS + Credential 사용
velero install \
--provider aws \
--bucket velero \
--secret-file ./minio.credentials \
--backup-location-config region=minio,s3ForcePathStyle=true,s3Url=http://{cluster-ip}:9000 \
--plugins velero/velero-plugin-for-aws:v1.1.0 \
--use-volume-snapshots=false

Test Namespace 생성


kubectl create namespace test
kubectl apply -f https://k8s.io/examples/controllers/nginx-deployment.yaml -n test

Velero Backup


# Namespace Backup
velero backup create backup --include-namespaces test

# Namespace Exclude Backup
velero backup create 231206-backup --exclude-namespaces kube-system,velero

주기적 Backup (Scheduling)


# 백업 스케줄링 예시
velero schedule create backup --schedule="*/10 * * * *" --exclude-namespaces kube-system,velero

#예상 결과물
velero backup get
NAME                          STATUS      ERRORS   WARNINGS   CREATED                         EXPIRES   STORAGE LOCATION   SELECTOR
backup-20220209044049    Completed   0        0          2022-02-09 13:40:49 +0900 KST   29d       default            <none>
backup-20220209043115    Completed   0        0          2022-02-09 13:31:15 +0900 KST   29d       default            <none>

Velero Restore


# Restore
velero create restore --from-backup test-backup

주의 사항


[주의]
스토리지 클래스(StorageClass) 자원은 백업 및 복구되지 않으므로, 
복구 전에 백업 클러스터에 존재하는 것과 동일한 이름의 스토리지 클래스를 
복구 클러스터에 미리 생성해 두어야 합니다.

[주의]
백업 클러스터와 복구 클러스터의 버전이 다른 경우 복구 시 문제가 발생할 수 있습니다.

논의 필요 사항


Backup 주기 결정

NS별로 백업을 할지 or 몇몇 NS 제외하고 전체 백업할지 결정

만약 제외방식 선택 시 Backup에서 제외해야할 NS 결정

참고


https://docs.nhncloud.com/ko/Container/NKS/ko/backup-guide/

profile
기록을 남겨보자

0개의 댓글