- Create a deployment to verify the restore in the end
k create deploy nginx-test --image=nginx
2. Update the cert path as per /etc/kubernetes/mainifest/etcd.yaml
ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \
--cacert=<trusted-ca-file> \
--cert=<cert-file> --key=<key-file> \
snapshot save /tmp/etcd.backup
2. Stop kubelet
systemctl stop kubelet
3. Stop kube-api and etcd
mv /etc/kubernetes/manifests/kube-apiserver.yaml /root/
mv /etc/kubernetes/manifests/etcd.yaml /root/
4. Restore the etcd.backup
ETCDCTL_API=3 etcdctl --endpoints 127.0.0.1:2379 snapshot restore etcd.backup
It will create “default.etcd” directory in current directory
[root@lp-k8control-1 etcd]# ls default.etcd/
member
5. Look at /etc/kubernetes/manifests/etcd.yaml etcd-data (/var/lib/etcd) directory path
[root@lp-k8control-1 default.etcd]# ls /var/lib/etcd
member
6. Copy member directory content from default.etcd to /var/lib/etcd
7. Start kube-api and etcd
mv /root/kube-apiserver.yaml /etc/kubernetes/manifests/kube-apiserver.yaml
mv /root/etcd.yaml /etc/kubernetes/manifests/etcd.yaml
8. Restart kubelet service
systemctl restart kubelet
9. Verify if nginx deployment we created in step 1 is restored
k get deploy