Question
Take a backup of ETCD database and save it to /root with the name of etcd-backup.db
Answer
Inspect the environment. Check how the etcd is running:
kubectl -n kube-system get po
We can see that etcd is running as static pod.kubectl -n kube-system describe po etcd-controlplane
Go to the Kubernetes documentation page and search for etcd snapshot sample command. This will look like this one:
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 }}
Replace the certificates, backup path and endpoints. In this case the command became:
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 etcd-backup.db
as we are on controlplane now, the endpoint is localhost