[Mock2_1] etcd backup

유유·2023년 2월 1일
0

CKA

목록 보기
10/19

Take a backup of the etcd cluster and save it to /opt/etcd-backup.db.

https://kubernetes.io/docs/tasks/administer-cluster/configure-upgrade-etcd/#restoring-an-etcd-cluster

*template*
ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
  --cacert=<trusted-ca-file> --cert=<cert-file> --key=<key-file> \
  snapshot save <backup-file-location>

**solve**
ETCDCTL_API=3 etcdctl --endpoints 10.26.59.12:2379   \
--cert=/etc/kubernetes/pki/etcd/server.crt   \
--key=/etc/kubernetes/pki/etcd/server.key  \
--cacert=/etc/kubernetes/pki/etcd/ca.crt  \
snapshot save /opt/etcd-backup.db

>> 문제가 쩜 이상하다 endpoint값은 pod ip

다른 문제
First, create a snapshot of the existing etcd instance running at https://127.0.0.1:2379 ,

saving the snapshot to /data/etcd-snapshot.db.

Next, restore an existing, previous snapshot located at /data/etcd-snapshot-previous.db.

The following TLS certificates/key are supplied for connecting to the server with etcdctl:

CA certificate: /etc/Kubernetes/pki/etcd/ca.crt

Client certificate: /etc/Kubernetes/pki/etcd/server.crt

Client key: /etc/Kubernetes/pki/etcd/server.key
  1. create a snapshot of the existing etcd instance running at https://127.0.0.1:2379
ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/server.crt \
--key=/etc/kubernetes/pki/etcd/server.key \
snapshot save /data/etcd-snapshot.db.
  1. restore an existing, previous snapshot located at /data/etcd-snapshot-previous.db.

cat /data/etcd-snapshot-previous.db.

  • 해당 경로에 스냅샷 파일이 있을 것
***template***
ETCDCTL_API=3 etcdctl snapshot restore \
--data-dir <data-dir-location> \
snapshotdb

***solve***

ETCDCTL_API=3 etcdctl snapshot restore \
--data-dir /var/lib/etcd-new \
/data/etcd-snapshot.db.

**3) 스냅샷 이미지가 잘 적용되었는지 확인**

```bash
sudo tree /var/lib/etcd-new

4)  현재 동작중인 etcd - pod 에 etcd-new가 새로운 데이터 저장소임을 알려줘야 함.

etcd pod 는 static pod의 형태로 작동중임

static pod 는 해당 경로에 yaml파일 형태로 있음.

cd /etc/kubernetes/manifests/
ls

5) etcd pod 에 변경된 etcd 경로로 지정

hostPath 의 path 에 새로운 경로를 지정해주면 됨.

vi /etc/kubernetes/manifests/etcd.yaml

6) up 상태 확인

: Exited 된 이후 UP 이 되면 됨. (시간 소요 됨)

docker ps -a | grep etcd

profile
하이

0개의 댓글