๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿš€ Backend

k8s - CKA ์˜ˆ์ œ ๋ฌธ์ œ Etcd backup & Restore

by dev.py 2022. 8. 22.

๋Œ€ํ‘œ์ ์ธ ๋ฌธ์ œ๋กœ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์˜ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๊ฐ€ ๋ชจ์—ฌ ์žˆ๋Š” etcd๋ฅผ ๋ฐฑ์—…ํ•˜๊ณ  

 

์ „์— ๋ฐฑ์—…ํ•œ ๋ฐ์ดํ„ฐ๋กœ ๋˜๋Œ๋ฆฌ๋Š” ์ž‘์—…์ด๋‹ค.

 

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๋ฌธ์„œ

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

 

Operating etcd clusters for Kubernetes

etcd is a consistent and highly-available key value store used as Kubernetes' backing store for all cluster data. If your Kubernetes cluster uses etcd as its backing store, make sure you have a back up plan for those data. You can find in-depth information

kubernetes.io

https://www.youtube.com/watch?v=dv_5WCYS5P8 

 

๊ธฐ๋ณธ etcd์˜ ๊ฒฝ๋กœ์ด๋‹ค

/var/lib/etcd

 

 

๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด ํ˜„์žฌ etcd์˜ ์ƒํƒœ๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๊ณ 

Sudo 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>

๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ํ†ตํ•ด snapshot๋ฅผ ๋””๋ ‰ํ† ๋ฆฌ์— ํ’€๊ฒŒ ๋˜๊ณ 

sudo ETCDCTL_API=3 etcdctl \
--data-dir <data-dir-location> \
snapshot restore snapshotdb

etcd๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” Pod์˜ Yaml ํŒŒ์ผ ์œ„์น˜

/etc/kubernetes/manifests/etcd.yaml

 

-hostPath:
 path : ~~~~

 

๋ฅผ ์ˆ˜์ •ํ•˜๊ฒŒ ํ•˜๊ฒŒ ๋˜๋ฉด etcd Pod Static ์ด๊ธฐ์— restart๋ฅผ ์ž๋™์ ์œผ๋กœ ํ•œ ํ›„, ์ ์šฉ์ด ๋œ๋‹ค