1. 리소스 설정 백업
kubectl get all -A -o yaml > backup.yaml
2. ETCD 백업
export ETCDCTL_API=3
- ETCD 파드의 설정 정보 확인
kubectl get po [etcd_파드이름] -o yaml -n kube-system
ex) kubectl get po etcd-controlplane -o yaml -n kube-system
- ETCD 스냅샷 생성
etcdctl snapshot save --cacert=[trusted-ca-file] --cert=[cert-file] --key=[key-file] [스냅샷_저장경로]
ex) etcdctl snapshot save --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key /opt/snapshot-pre-boot.db
- ETCD 복구
etcdctl snapshot restore --cacert=[trusted-ca-file] --cert=[cert-file] --key=[key-file] --data-dir=[변경할_데이터_디렉터리_경로] [스냅샷_저장경로]
ex) etcdctl snapshot restore --cacert=/etc/kubernetes/pki/etcd/ca.crt --cert=/etc/kubernetes/pki/etcd/ca.crt --key=/etc/kubernetes/pki/etcd/server.key --data-dir=/var/lib/etcd-backup /opt/snapshot-pre-boot.db
- ETCD 정적 파드 설정(/etc/kubernetes/manifests/etcd.yaml) 중 --data-dir을 [변경할데이터디렉터리_경로]로 변경
참고
- https://www.udemy.com/course/certified-kubernetes-administrator-with-practice-tests/