1. EBS Volume Snapshot Controller
➜ PV로 사용하고 있는 중요한 EBS를 EKS에서 바로 Snapshot으로 백업할 수 있는 서비스
➜ 설치
✅ CRD 설치
curl -s -O https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/master/client/config/crd/snapshot.storage.k8s.io_volumesnapshots.yaml
curl -s -O https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/master/client/config/crd/snapshot.storage.k8s.io_volumesnapshotclasses.yaml
curl -s -O https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/master/client/config/crd/snapshot.storage.k8s.io_volumesnapshotcontents.yaml
✅ CRD 리소스 확인
kubectl get crd | grep snapshot
kubectl api-resources | grep snapshot
✅ Snapshot Controller 설치
curl -s -O https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/master/deploy/kubernetes/snapshot-controller/rbac-snapshot-controller.yaml
curl -s -O https://raw.githubusercontent.com/kubernetes-csi/external-snapshotter/master/deploy/kubernetes/snapshot-controller/setup-snapshot-controller.yaml
kubectl apply -f rbac-snapshot-controller.yaml,setup-snapshot-controller.yaml
➜ Test Pod 배포
✅ kubectl apply -f snapshotclass.yaml
✅ kubectl get pv,pvc

✅ kubectl exec ebs-dp-app -- tail -f /data/out.txt

✅ nano ebs_vol_snapshot.yaml
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
name: ebs-volume-snapshot
spec:
volumeSnapshotClassName: csi-aws-vsc
source:
persistentVolumeClaimName: ebs-dp-claim
✅ kubectl apply -f ebs_vol_snapshot.yaml
✅ kubectl get volumesnapshot

✅ AWS volume 생성된 것 확인

➜ 파드와 PVC 강제 삭제 => 지금까지 설정한 reclaim policy는 delete 이므로 PVC삭제되면 PV도 삭제됨
✅ kubectl delete pod ebs-dp-app
✅ kubectl delete pvc ebs-dp-claim
➜ ebs 볼륨 스냅샷 복원
✅ 스냅샷 복원 용도의 PVC와 파드 생성
✅ ebs_snapshot_restore_pvc.yaml 파일 생성
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ebs-snapshot-restored-claim
spec:
accessModes:
- ReadWriteOnce
storageClassName: ebs-dp-sc
resources:
requests:
storage: 4Gi
dataSource:
kind: VolumeSnapshot
name: ebs-volume-snapshot
apiGroup: snapshot.storage.k8s.io
✅ kubectl apply -f ebs_snapshot_restore_pvc.yaml
✅ nano ebs_snapshot_restore_pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: ebs-dp-app
spec:
containers:
- name: app
image: centos
command: ["/bin/sh"]
args: ["-c", "while true; do echo $(date -u) >> /data/out.txt; sleep 10; done"]
volumeMounts:
- name: persistent-storage
mountPath: /data
volumes:
- name: persistent-storage
persistentVolumeClaim:
claimName: ebs-snapshot-restored-claim
✅ kubectl apply -f ebs_snapshot_restore_pod.yaml
✅ kubectl get pv,pvc,sc
✅ kubectl exec ebs-dp-app --head /data/out.txt
✅ kubectl exec ebs-dp-app -- tail -f /data/out.txt
✅ 참고
https://kubernetes.io/docs/concepts/storage/volume-pvc-datasource/
CSI Volume Cloning
This document describes the concept of cloning existing CSI Volumes in Kubernetes. Familiarity with Volumes is suggested. Introduction The CSI Volume Cloning feature adds support for specifying existing PVCs in the dataSource field to indicate a user would
kubernetes.io
'AWS' 카테고리의 다른 글
| [ 8 ] - External DNS (0) | 2024.09.27 |
|---|---|
| [ 7 ] - EKS Storage Monitoring (0) | 2024.09.26 |
| [ 5 ] - pv, pvc 관련 실습 (0) | 2024.09.25 |
| [ 4 ] (0) | 2024.09.13 |
| [ 3 ] (0) | 2024.09.12 |