velero
Kubernetes 클러스터 리소스 및 영구 볼륨을 백업 및 복원 할 수있는 도구.
AWS, GCP, Azure 와 연동하여 구축이 가능.
on-premise 환경에선 minio와 호환하여 구축 가능
1 | kubectl create secret generic cloud-credentials --namespace <VELERO_NAMESPACE> --from-file cloud=<FILE_NAME> | cs |
minio 페이지에서 다양한 설치 방법을 제공하고 있다.
Standalone, Distributed 두 가지 설치 방법이 있으며, 하나의 노드에 대해 설치를 진행할 때는 standalone으로 진행하고, 클러스터 환경에선 distributed 로 진행하면 된다.
distributed는 최소 4대의 노드가 필요하며, 쿠버네티스 설치에 대해서는 두 가지로 설치를 진행이 가능하다.
statefulset 설치를 위한 yaml 파일을 생성하여 배포하는 방법과 helm 차트에서 설치가 가능하다.
accessKey와 secretKey에는 특수문자를 넣으면 안된다.
helm 차트에 등록되어 있는 minio를 설치 가능하다.
helm 차트를 이용할 경우 access_key, secret_key 등에 대한 옵션을 추가해서 설치를 진행해야 한다.
on-premise 환경 진행이므로 PV, PVC 를 미리 생성 후 연결하여 배포를 진행해야한다.
hostPath가 아닌 local-storage를 연동해야 분산환경에서 각 노드간에 저장된 내용 공유가 가능하다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | apiVersion: v1 kind: PersistentVolume metadata: name: minio-local-volume namespace: velero spec: capacity: storage: 5G accessModes: - ReadWriteMany volumeMode: Filesystem storageClassName: "local-storage" local: path: /data/minio nodeAffinity: required: nodeSelectorTerms: - matchExpressions: - key: kubernetes.io/hostname operator: In values: - "node-dev1" - "node-dev2" - "node-dev3" - "node-dev4" - "node-dev5" - "node-dev6" claimRef: namespace: velero name: minio-local-volume-claim --- apiVersion: v1 kind: PersistentVolumeClaim metadata: name: minio-local-volume-claim namespace: velero spec: accessModes: - ReadWriteMany resources: requests: storage: 5G storageClassName: local-storage volumeMode: Filesystem | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | apiVersion: v1 kind: Service metadata: name: minio namespace: velero labels: app: minio spec: clusterIP: None ports: - port: 9000 name: minio selector: app: minio --- apiVersion: apps/v1beta1 kind: StatefulSet metadata: name: minio namespace: velero spec: serviceName: minio replicas: 4 template: metadata: labels: app: minio spec: volumes: - name: data persistentVolumeClaim: claimName: minio-local-volume-claim containers: - name: minio env: - name: MINIO_ACCESS_KEY ## velero 연동 시 사용되는 정보 value: "minio" - name: MINIO_SECRET_KEY value: "minio123" image: minio/minio:latest args: - server - http://minio-{0...3}.minio.velero.svc.cluster.local/data # 4대의 분산 노드와 통신하기 위한 service 내부 도메인 / 도메인 뒤에 url 경로는 volume 매핑되는 폴더 경로 ports: - containerPort: 9000 volumeMounts: - name: data mountPath: /data --- apiVersion: v1 kind: Service metadata: name: minio-service namespace: velero spec: type: NodePort ports: - port: 9000 targetPort: 9000 protocol: TCP nodePort: 32099 selector: app: minio | cs |
볼륨 경로가 잘못되지 않는 상황이면 대부분 배포에 문제는 발생하지 않는다.
storage 특성 때문인지 처음 설치 후에 replicas 수가 조정되면 초기화 에러 및 상태 공유가 안되는 이슈가 발생한다.
처음 구축 시에 사용할 노드에 대해 설계 완료 후 사용 권장한다.
이 후 설치한 <url>:32099로 접속하게 되면 화면이 출력되고 설장한 accessKey와 secretKey로 로그인하면 된다.
velero 서버 구축
velero 사용을 위해서는 velero 서버 구축이 필요하며, 클라이언트 설치가 필요하다.
release 정보 페이지 : https://github.com/vmware-tanzu/velero/releases
1 2 3 | wget <RELEASE-TARBALL-URL> tar -xvf <RELEASE-TARBALL-NAME>.tar.gz -C /dir/to/extract/to cp /dir/to/extract/to/velero /usr/local/bin | cs |
1 2 3 | [default] aws_access_key_id = minio aws_secret_access_key = minio123 | cs |
velero 서버 설치를 진행. --backup-location-config 옵션 값은 minio 연동 위한 값으로 모두 넣어줘야 한다.
또한 velero install 전에 --bucket 옵션으로 주어지는 bucket이 minio에 생성되어 있어야한다.\
1 2 3 4 5 6 7 8 | velero install \ --provider aws \ --bucket velero \ --secret-file ./cloud-credentials \ --use-volume-snapshots=false \ --backup-location-config region=minio,s3ForcePathStyle="true",s3Url=http://minio.velero.svc:9000,publicUrl=<minio가 설치된 서버:포트번호> # 1.2.0 버전 업되면서 install 옵션이 추가 --plugins velero/velero-plugin-for-aws:v1.0.0,velero/velero-plugin-for-microsoft-azure:v1.0.0,velero/velero-plugin-for-gcp:v1.0.0 | cs |
설치가 진행 되면 관련 서버 및 resource 설치가 진행된다. backup-location 리소스 이름이 default인데 인증키 정보 파일의 인증 정보 탭이름을 일치시켜줘야 한다.
모든 설치 완료 후 버전 확인을 하면 클라이언트 버전과 서버 버전이 모두 보여진다. 제대로 설치가 되지 않으면 server 버전정보가 표시 되지 않는다.
1 2 3 4 5 6 | $ velero version Client : Version: v1.1.0 Git commit: <commit hash data> Server: Version: v1.1.0 # minio와 연동 실패 등으로 서버가 제대로 구동되지 않을 수 있다. | cs |
1 2 | kubectl delete namespace/velero clusterrolebinding/velero # 재설치의 경우 굳이 삭제하지 않아도 된다. kubectl delete crds -l component=velero | cs |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # 네임스페이스 지정 $ velero backup create <BACKUP_NAME> --include-namespaces tpas,heimdall,kafka # 특정 네임스페이스 제외 $ velero backup create <BACKUP_NAME> --exclude-namespaces default,kube-system # 네임스페이스의 특정 리소스 제외 $ velero backup create <BACKUP_NAME> --include-namespaces tpas,heimdall,kafka --exclude-resources ingress,service # 백업 데이터 확인 / 어떤 리소스가 백업되어 있는지 확인 가능 $ velero backup describe <BACKUP_NAME> --details | cs |
생성이 되면 해당 리소스들에 대한 정보가 json화 되어 연동된 minio에 생성한 bucket에 저장된다.
bucket 저장된 데이터는 압축된 데이터로 따로 다운받아서 확인 가능하며, describe 명령어로 백업 리소스 리스트를 확인 가능하다.
1 | velero restore create <restore-name> --from-backup <backup-name> | cs |
1 | velero schedule create <schedule-name> --schedule="0 1 * * * or @daily" --include-resources deployments,service | cs |
1 2 3 4 5 6 7 | Entry | Description | Equivalent To ----- | ----------- | ------------- @yearly (or @annually) | Run once a year, midnight, Jan. 1st | 0 0 1 1 * @monthly | Run once a month, midnight, first of month | 0 0 1 * * @weekly | Run once a week, midnight between Sat/Sun | 0 0 * * 0 @daily (or @midnight) | Run once a day, midnight | 0 0 * * * @hourly | Run once an hour, beginning of hour | 0 * * * * | cs |
1 | velero backup delete <backup-name> | cs |




