본문 바로가기
DevOps 잡다구리/Kubernetes Stuff

[Kubernetes] Volsync rclone replication 을 통한 데이터 백업

by WhiteGoblin 2021. 11. 29.
반응형

최근 회사에서 데이터 백업 관련되어서 고민을 하게 되었고 신기한 프로그램을 찾게 되었다. 

 

쿠버네티스 환경에서는 우선 컨테이너 환경이기 때문에 컨테이너의 데이터는 날아가게 되어 있다. 

 

하지만 이러한 것을 방지하기 위해서 PVC 를 이용하여서 PV 를 잡는다. 이렇게 하면 컨테이너가 내려가게 되어도 데이터는 보존되고 해당

 

데이터는 차후에 다시 복원하는데 이용할 수 있다. 

 

이러한 PVC 를 이용해서 데이터를 그대로 복제하는 tool 인 volsync 를 이용하게 되었다. 

 

https://volsync.readthedocs.io/en/latest/index.html

 

Overview — VolSync documentation

© Copyright 2020, The VolSync authors. Revision 0aafaf4c.

volsync.readthedocs.io

 

현재 한글화가 되어 있지 않지만 내용은 무척이나 간단하다

 

rsync 를 이용하여서 데이터를 복제하는 방안
Rclone , restic 을 활용하여서 데이터 복원

그림 출처: https://next.redhat.com/2021/08/23/introducing-volsync-your-data-anywhere/

 

Introducing VolSync: your data, anywhere - Red Hat Emerging Technologies

Organizations face a challenging task of identifying and developing data storage, backup, recovery, and migration solutions for the enterprise. There are a wide variety of tools and solutions in the ecosystem that work well with traditional legacy-type env

next.redhat.com

 

1. 설치 

 

우선 snapshot operator 가 필요하다. 

https://github.com/kubernetes-csi/external-snapshotter

 

GitHub - kubernetes-csi/external-snapshotter: Sidecar container that watches Kubernetes Snapshot CRD objects and triggers Create

Sidecar container that watches Kubernetes Snapshot CRD objects and triggers CreateSnapshot/DeleteSnapshot against a CSI endpoint. - GitHub - kubernetes-csi/external-snapshotter: Sidecar container t...

github.com

 

해당 URL 를 사용해서 간단하게 설치 할 수도 있지만 친절하게도 volsync 에서 정리 해둔 스크립트를 이용해서 간단하게 설치 할 수 있다. 

 

  kubectl create -f "https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${TAG}/client/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml"
  kubectl create -f "https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${TAG}/client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml"
  kubectl create -f "https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${TAG}/client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml"

  kubectl create -f "https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${TAG}/deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml"
  kubectl create -f "https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/${TAG}/deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml"

 

이후 필자는 helm chart 를 통해서 설치를 손쉽게 이루었다. 

 

# Add the Backube Helm repo
$ helm repo add backube https://backube.github.io/helm-charts/

# Deploy the chart in your cluster
$ helm install --create-namespace -n volsync-system volsync backube/volsync

 

이후 pod 에서 확인하면 volsync 가 돌아가고 있다는 사실을 알 수 있다. 

 

이후 2가지 data mover 를 만들어서 데이터를 백업할 수 있는데 

 

1. source 

- pvc 를 지정해서 해당 pvc 로 부터 데이터를 volsyn pvc 밑에 데이터를 백업하게 된다. 

 

2. dest 

- rclone 이나 다른 툴을 이용해서 해당 데이터를 minio 나 다른 스토리지 버켓으로 부터 데이터를 백업하게 된다. 

 

필자는 실제로 둘다 해보고 둘다 되는것을 확인 했다. 

 

해당 설정은 doc 에서 설정되어 있어서 자세한 설명은 생략한다. 

 

데이터 백업을 고민중이라면 괜찮은 옵션중 하나인것은 분명하다. 

 

하지만 실제 적용하다가 한번은 클러스터에서 데이터를 백업하는 포드가 생성되지 않아서 데이터 백업 작업 자체가 진행되지 않은 경우가 있어서 추가적으로 검증을 하고 사용하는 것을 추천한다. 

반응형