Kubernetes 백업 및 복구 솔루션 비교 (Velero, Kasten)

2022. 5. 30. 17:56Cloud Computing/Kubernetes

Kuberntes 는 다양한 환경에서 사용되고 있습니다. 보다 많은 Workload 를 수용하고, Mission Critical 서비스를 적용하는 사례가 늘고 있습니다. 그러나 백업/복구 체계가 잘 갖춰진 사이트는 그렇게 많지 않습니다. 

 

이전부터 Legacy 환경에서는 Agent 방식을 사용해 OS,Data 영역을 백업/복구해 왔으며, IaaS 기반 가상화 환경에서는 VM 을 Image 상태로 저장하고 손쉽게 복원할 수 있습니다. 하지만 k8s 환경에서는 앞서 얘기한 두가지 방식으로는 온전히 백업/복구를 수행할 수 없습니다. 

쿠버네티스 환경에서는 크게 아래 항목들이 백업 대상에 포함되어야 합니다.

  • Dockerfile 또는 Container Image 
  • Persistent volume (storage) 
  • etcd (cluster DB)
  • kubernetes resource (manifest file) 

Velero 

velero 는 vmware 에서 관리하는 Kubernetes 클러스터 오픈 소스 백업 및 DR 툴입니다(이전 Heptio Ark. 전체 클러스터 또는 개별 네임스페이스 또는 레이블의 예약된 백업을 실행할 수 있도록 합니다. 다른 툴이 etcd 에 직접 접근하여 백업을 수행하는 반면, velero 는 API 를 사용하여 리소스 상태를 저장하고 복구합니다. 이런 API-Driven 방식 tool 의 이점은 아래와 같습니다 .

  • namespace, resource type, label selector별로 선택하여 리소스를 캡쳐할 수 있으므로 백업/복구의 유연성이 높습니다. 
  • CSP 의 관리형 k8s 를 사용하는 경우 etcd 를 직접 접근할 수 없지만 API 는 가능합니다.

또한 아래와 같이 구성됩니다. 

  • k8s 클러스터 내 설치되는 Pod 형태의 Server
  • command-line client (사용자 PC)
  • Object Stroage (백업 파일 저장)

  1. The Velero client makes a call to the Kubernetes API server to create a Backup object.
  2. The BackupController notices the new Backup object and performs validation.
  3. The BackupController begins the backup process. It collects the data to back up by querying the API server for resources.
  4. The BackupController makes a call to the object storage service – for example, AWS S3 – to upload the backup file.

Install  

공식 velero Docs 및 다른 blog 에서도 설치과정은 쉽게 찾을 수 있기에 본 Post 에서는 상세 설치 과정은 생략합니다. 

Prerequisites

  • kubernetes 클러스터가 접근 가능한 Clinet (kubectl 수행 가능) 

Install CLI 

Client 운영체제에 따라 설치 (자세한 내용은 https://velero.io/docs/v1.8/basic-install/ 참조. '22년 3월 기준 최신 버전은 v1.8) 

  • MacOS - Homebrew 
  • GitHub release (tar) 
  • Windows - chocloatey 

Install and configure the server components

Cluster Provider 환경에 따라 설치 (자세한 내용은 https://velero.io/docs/v1.8/supported-providers/ 참조) - 아래는 AWS 기준 

    • Create S3 buckek ( 백업 파일 저장 용도 ) 
    • Set permissions for Velero ( S3 접근 권한 설정 )
    • Install and start Velero ( 클러스터 내 velero server 배포 ) 

 

Use 

Case 에 따라 DR, Cluster migration, 정기/임시 백업 등 다양한 목적으로 사용할 수 있으며 아래는 전체 클러스터 백업(PV 포함), 특정 네임스페이스 복구를 테스트해 봤습니다. 

 

  • 현재 클러스터 내 resource 확인 
(⎈ |jhs-eks-work-cluster:wordpress-cwi) eks-velero  k get all -A
NAMESPACE       NAME                                             READY   STATUS      RESTARTS   AGE
eks-work        pod/appjs-pbn5q                                  1/1     Running     0          7d22h
eks-work        pod/backend-app-7dccc69568-bxpqm                 1/1     Running     0          7d7h
eks-work        pod/backend-app-7dccc69568-mdxrk                 1/1     Running     0          7d7h
eks-work        pod/batch-app-27475710-tqj7v                     0/1     Completed   0          10m
eks-work        pod/batch-app-27475715-8pc95                     0/1     Completed   0          5m21s
eks-work        pod/batch-app-27475720-trvjk                     0/1     Completed   0          21s
eks-work        pod/centos-64ff4d9b-57ld6                        1/1     Running     0          7d22h
eks-work        pod/network-test                                 1/1     Running     0          8d
eks-work        pod/nginx-pod                                    1/1     Running     0          8d
kube-system     pod/aws-node-jlnqb                               1/1     Running     0          10d
kube-system     pod/aws-node-twzkj                               1/1     Running     0          10d
kube-system     pod/coredns-6dbb778559-2lfg4                     1/1     Running     0          10d
kube-system     pod/coredns-6dbb778559-4zgpr                     1/1     Running     0          10d
kube-system     pod/kube-proxy-96pv5                             1/1     Running     0          10d
kube-system     pod/kube-proxy-mczbt                             1/1     Running     0          10d
kube-system     pod/metrics-server-64cf6869bd-j62vx              1/1     Running     0          10d
velero          pod/velero-879fff5fc-j9prd                       1/1     Running     0          4d2h
wordpress-cwi   pod/understood-zebu-mariadb-0                    1/1     Running     0          4d21h
wordpress-cwi   pod/understood-zebu-wordpress-68fbc786c4-vz65r   1/1     Running     0          4d21h

NAMESPACE       NAME                                TYPE           CLUSTER-IP       EXTERNAL-IP                                                                    PORT(S)                      AGE
default         service/kubernetes                  ClusterIP      10.100.0.1       <none>                                                                         443/TCP                      10d
eks-work        service/backend-app-service         LoadBalancer   10.100.252.166   a7fd24eb308c743f7a7a34962327bb36-1014081366.ap-northeast-2.elb.amazonaws.com   8080:30907/TCP               7d6h
kube-system     service/kube-dns                    ClusterIP      10.100.0.10      <none>                                                                         53/UDP,53/TCP                10d
kube-system     service/metrics-server              ClusterIP      10.100.245.118   <none>                                                                         443/TCP                      10d
wordpress-cwi   service/understood-zebu-mariadb     ClusterIP      10.100.111.97    <none>                                                                         3306/TCP                     4d21h
wordpress-cwi   service/understood-zebu-wordpress   LoadBalancer   10.100.233.186   a12b1077cb2b94cfb92c6b0f8e19e5c6-798956363.ap-northeast-2.elb.amazonaws.com    80:31877/TCP,443:30075/TCP   4d21h

NAMESPACE     NAME                        DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
kube-system   daemonset.apps/aws-node     2         2         2       2            2           <none>          10d
kube-system   daemonset.apps/kube-proxy   2         2         2       2            2           <none>          10d

NAMESPACE       NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
eks-work        deployment.apps/backend-app                 2/2     2            2           7d7h
eks-work        deployment.apps/centos                      1/1     1            1           7d22h
kube-system     deployment.apps/coredns                     2/2     2            2           10d
kube-system     deployment.apps/metrics-server              1/1     1            1           10d
velero          deployment.apps/velero                      1/1     1            1           4d2h
wordpress-cwi   deployment.apps/understood-zebu-wordpress   1/1     1            1           4d21h

NAMESPACE       NAME                                                   DESIRED   CURRENT   READY   AGE
eks-work        replicaset.apps/appjs                                  1         1         1       7d22h
eks-work        replicaset.apps/backend-app-7dccc69568                 2         2         2       7d7h
eks-work        replicaset.apps/centos-64ff4d9b                        1         1         1       7d22h
kube-system     replicaset.apps/coredns-6dbb778559                     2         2         2       10d
kube-system     replicaset.apps/metrics-server-64cf6869bd              1         1         1       10d
velero          replicaset.apps/velero-879fff5fc                       1         1         1       4d2h
wordpress-cwi   replicaset.apps/understood-zebu-wordpress-68fbc786c4   1         1         1       4d21h

NAMESPACE       NAME                                       READY   AGE
wordpress-cwi   statefulset.apps/understood-zebu-mariadb   1/1     4d21h

NAMESPACE   NAME                      SCHEDULE      SUSPEND   ACTIVE   LAST SCHEDULE   AGE
eks-work    cronjob.batch/batch-app   */5 * * * *   False     0        22s             6d23h

NAMESPACE   NAME                           COMPLETIONS   DURATION   AGE
eks-work    job.batch/batch-app-27475710   1/1           10s        10m
eks-work    job.batch/batch-app-27475715   1/1           10s        5m22s
eks-work    job.batch/batch-app-27475720   1/1           10s        22s
(⎈ |jhs-eks-work-cluster:wordpress-cwi) eks-velero 
(⎈ |jhs-eks-work-cluster:wordpress-cwi) eks-velero  k get pv
NAME                                       CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                                          STORAGECLASS   REASON   AGE
pvc-9f7733ef-2cb3-479c-ad4e-cd16cd1e94d1   8Gi        RWO            Delete           Bound    wordpress-cwi/data-understood-zebu-mariadb-0   gp2                     4d21h
pvc-f555d44a-93e1-4773-9e06-d8aef53142a3   10Gi       RWO            Delete           Bound    wordpress-cwi/understood-zebu-wordpress        gp2                     4d21h

 

  • 클러스터 전체 백업 
    • 552 개 item 및 2개 pv (block strage) 에 대해 백업 완료 : 8초 소요 
    • 보다 많은 workload 가 실행 중인 다른 클러스터도 수분 내에 백업 완료됨  
(⎈ |jhs-eks-work-cluster:wordpress-cwi) eks-velero  velero backup create first
Backup request "first" submitted successfully.
Run `velero backup describe first` or `velero backup logs first` for more details.
(⎈ |jhs-eks-work-cluster:wordpress-cwi) eks-velero  velero backup describe first
Name:         first
Namespace:    velero
Labels:       velero.io/storage-location=default
Annotations:  velero.io/source-cluster-k8s-gitversion=v1.21.5-eks-bc4871b
              velero.io/source-cluster-k8s-major-version=1
              velero.io/source-cluster-k8s-minor-version=21+

Phase:  Completed

Errors:    0
Warnings:  0

Namespaces:
  Included:  *
  Excluded:  <none>

Resources:
  Included:        *
  Excluded:        <none>
  Cluster-scoped:  auto

Label selector:  <none>

Storage Location:  default

Velero-Native Snapshot PVs:  auto

TTL:  720h0m0s

Hooks:  <none>

Backup Format Version:  1.1.0

Started:    2022-03-25 15:22:58 +0900 KST
Completed:  2022-03-25 15:23:06 +0900 KST

Expiration:  2022-04-24 15:22:58 +0900 KST

Total items to be backed up:  552
Items backed up:              552

Velero-Native Snapshots:  2 of 2 snapshots completed successfully (specify --details for more information)
  • 워드프레스가 설치된 wordpress-cwi namespace 삭제 ( 실수로 가정 )
### namespace 삭제 (해당 namespace 상 모든 resource 삭제) 
(⎈ |jhs-eks-work-cluster:default) eks-velero  k delete ns wordpress-cwi
namespace "wordpress-cwi" deleted
(⎈ |jhs-eks-work-cluster:default) eks-velero  k get all -n wordpress-cwi
No resources found in wordpress-cwi namespace.
(⎈ |jhs-eks-work-cluster:default) eks-velero  k get pv
No resources found
(⎈ |jhs-eks-work-cluster:default) eks-velero  helm3 list -A
NAME	NAMESPACE	REVISION	UPDATED	STATUS	CHART	APP VERSION
(⎈ |jhs-eks-work-cluster:default) eks-velero 
(⎈ |jhs-eks-work-cluster:default) eks-velero 

### velero 로 해당 namespace 만 복구 ( 26개 Item 에 대해 복구 3초 소요 ) 
(⎈ |jhs-eks-work-cluster:default) eks-velero  velero restore create --from-backup first --include-namespaces wordpress-cwi
Restore request "first-20220329180923" submitted successfully.
Run `velero restore describe first-20220329180923` or `velero restore logs first-20220329180923` for more details.
(⎈ |jhs-eks-work-cluster:default) eks-velero 
(⎈ |jhs-eks-work-cluster:default) eks-velero  velero restore describe first-20220329180923
Name:         first-20220329180923
Namespace:    velero
Labels:       <none>
Annotations:  <none>

Phase:                       Completed
Total items to be restored:  26
Items restored:              26

Started:    2022-03-29 18:09:26 +0900 KST
Completed:  2022-03-29 18:09:29 +0900 KST

Backup:  first

Namespaces:
  Included:  wordpress-cwi
  Excluded:  <none>

Resources:
  Included:        *
  Excluded:        nodes, events, events.events.k8s.io, backups.velero.io, restores.velero.io, resticrepositories.velero.io
  Cluster-scoped:  auto

Namespace mappings:  <none>

Label selector:  <none>

Restore PVs:  auto

Preserve Service NodePorts:  auto

### Pod 기동 중 
(⎈ |jhs-eks-work-cluster:default) eks-velero  k get all -n wordpress-cwi
NAME                                             READY   STATUS              RESTARTS   AGE
pod/understood-zebu-mariadb-0                    0/1     ContainerCreating   0          20s
pod/understood-zebu-wordpress-68fbc786c4-vz65r   0/1     ContainerCreating   0          20s

NAME                                TYPE           CLUSTER-IP      EXTERNAL-IP                                                                    PORT(S)                      AGE
service/understood-zebu-mariadb     ClusterIP      10.100.83.99    <none>                                                                         3306/TCP                     20s
service/understood-zebu-wordpress   LoadBalancer   10.100.15.218   aa74b993bd5b347c693e6e0553e0b7f1-1811961745.ap-northeast-2.elb.amazonaws.com   80:31402/TCP,443:31785/TCP   20s

NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/understood-zebu-wordpress   0/1     1            0           20s

NAME                                                   DESIRED   CURRENT   READY   AGE
replicaset.apps/understood-zebu-wordpress-68fbc786c4   1         1         0       20s

NAME                                       READY   AGE
statefulset.apps/understood-zebu-mariadb   0/1     19s

### 모든 Pod 기동 완료 및 helm release 복구 
(⎈ |jhs-eks-work-cluster:default) eks-velero  k get all -n wordpress-cwi
NAME                                             READY   STATUS    RESTARTS   AGE
pod/understood-zebu-mariadb-0                    1/1     Running   0          73s
pod/understood-zebu-wordpress-68fbc786c4-vz65r   1/1     Running   0          73s

NAME                                TYPE           CLUSTER-IP      EXTERNAL-IP                                                                    PORT(S)                      AGE
service/understood-zebu-mariadb     ClusterIP      10.100.83.99    <none>                                                                         3306/TCP                     73s
service/understood-zebu-wordpress   LoadBalancer   10.100.15.218   aa74b993bd5b347c693e6e0553e0b7f1-1811961745.ap-northeast-2.elb.amazonaws.com   80:31402/TCP,443:31785/TCP   73s

NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/understood-zebu-wordpress   1/1     1            1           73s

NAME                                                   DESIRED   CURRENT   READY   AGE
replicaset.apps/understood-zebu-wordpress-68fbc786c4   1         1         1       73s

NAME                                       READY   AGE
statefulset.apps/understood-zebu-mariadb   1/1     72s
(⎈ |jhs-eks-work-cluster:default) eks-velero 
(⎈ |jhs-eks-work-cluster:default) eks-velero  helm3 list -A
NAME           	NAMESPACE    	REVISION	UPDATED                             	STATUS  	CHART           	APP VERSION
understood-zebu	wordpress-cwi	1       	2022-03-24 19:47:30.365403 +0900 KST	deployed	wordpress-13.1.4	5.9.2
(⎈ |jhs-eks-work-cluster:default) eks-velero 

CLI 상에서도 모든 Resource 가 정상적으로 기동되었으며 실제 서비스도 문제 없음을 확인할 수 있습니다. 

상기 테스트에서는 namespace 단위의 백업/복구를 테스트했으나 velero 에서는 다양한 옵션의 백업/복구 기능을 지원합니다. (labelselector, TTL, Scheduling, incremental backup 등) 

 

Kasten K10

다음은 veeam 의 k8s 백업/복구 솔루션인 Kasten 입니다. 

veeam 은 veritas, Dell, commvault 등과 함께  백업/복구 영역에서 손꼽히는 솔루션 기업 중 하나입니다.

k8s 백업 솔루션인 kasten k10은 다양한 고객 및 글로벌 레퍼런스를 가지고 있는만큼 검증된 솔루션으로 볼 수 있습니다. 

사용하기 위해선 유료 라이선스가 필요하지만 10 Node 내 Non-product 클러스터를 대상으로 사용할 수 있는 free license 로 세팅해보겠습니다. 

 

구조는 앞서 살펴본 velero 와 유사하지만 GUI 환경 및 편의 기능을 위한 component 가 추가되어 있습니다. 

Install

velero 와 마찬가지로 본 Post 에서는 자세한 설치과정은 생략하고 AWS 에서의 개략적인 구성에 대해서만 다룹니다. 

2차 백업을 위한 File 또는 Object 스토리지 세팅 및 Export/Import 는 제외합니다. 

 

Prerequisites

  • Add the Kasten Helm charts repository
  • volumeSnapshot CRD 생성 ( volumesnapshotclasses, volumesnapshotcontents, volumesnapshots ) 
  • snapshot-controller 설치
  • snapshotclass 생성 (k10.kasten.io/is-snapshot-class: "true"  어노테이션 추가) 
  • Snapshotter 생성 ( AWS CSI driver 호환 ) 

Install (helm) 

helm install k10 kasten/k10 --namespace=kasten-io \
    --set secrets.awsAccessKeyId="${AWS_ACCESS_KEY_ID}" \
    --set secrets.awsSecretAccessKey="${AWS_SECRET_ACCESS_KEY}"

 

 

Use

  • Dashboard 에서 Backup Policy 생성 후 실행 

  • 지정한 Namespace 상의 모든 Resource 백업 현황 확인 

  • 백업한 리소스 중 특정 리소스만 선택하여 별도의 namespace (wordpress-hellozcp) 상에서 복구 테스트 

  • 복구 완료 후 서비스 확인 

(⎈ |jhs-eks-work-cluster:wordpress) work  k get deploy,svc -n wordpress-hellozcp
NAME                       READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/hellozcp   1/1     1            1           20m

NAME                   TYPE           CLUSTER-IP      EXTERNAL-IP                                                                   PORT(S)          AGE
service/hellozcp-svc   LoadBalancer   10.100.166.46   a2685b3d652124051a0f64d5263966eb-195969067.ap-northeast-2.elb.amazonaws.com   8080:30152/TCP   20m

(⎈ |jhs-eks-work-cluster:wordpress) work  k exec -it network-test -n eks-work -- curl 10.100.166.46:8080
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ZCP Sample Application</title>
</head>
<h1>Hello ZCP</h1>
<h2>Update test</h2>
<h2>Update test2</h2>
</body>
</html>%

 

Velero & K10 비교 

두 솔루션은 모두 kubernetes 의 특징을 잘 살려 백업 및 복구가 기존 Legacy 에 비해 신속하고 간편하게 진행됩니다. 

가장 큰 차이점이라고 한다면 라이선스 비용과 수행환경(CLI, GUI) 가 가장 큰 사항이라 생각됩니다. 

몇몇 테스트 후 정리한 차이점은 다음과 같습니다. 

  velero K10
비용 무료 유료 (worker node 기준)
사용자 Interface CLI GUI, CLI
개발 결정권 커뮤니티 벤더
설치 Resource velero deployment 1ea
(restic 사용시 restic daemonset 추가)
16 개 deploy, 18 개 service , 6 개 persistent volume 등
저장공간 Object storage File, Object storage
편의기능 백업,복구에 충실한 편 백업,복구 외 다양한 솔루션과의 인터페이스 제공 (eco-system)

 

두 솔루션 모두 백업 및 복구에 대해서는 훌륭한 성능을 보여주고 있다고 생각되며, 

어떤 솔루션을 도입할지는 비용, 사용자, 주변 환경 등을 고려해 선택해야 합니다.  

이번 포스트에서는 개략적인 내용만을 다뤘으니 혹시 사용 중 문의 사항이 있다면 연락 주시기 바랍니다. 

'Cloud Computing > Kubernetes' 카테고리의 다른 글

Docker Desktop 유료화 및 대응방안  (0) 2022.02.04