Etcd Backup and Restore (4)

Table of contents
Why Update etcd.yaml
?
In previous posts, we see we need to update the etcd.yaml
file to make the restore work. And the reason for this step is related to kubelet working mechanism.
Pod Reconciliation by kubelet:
The etcd
static pod is managed by the kubelet, which uses the etcd.yaml
manifest. If the manifest doesn't match the new data directory, the pod will continue using the old path, leading to a mismatch and potentially starting with stale or incorrect data. (For more workflow details, you can check my previous post.)
Based on above, when we restored etcd to a different directory, we must update the hostPath
in the manifest to match the new --data-dir
path.
How to Update the Manifest
- Locate the Manifest:
vi /etc/kubernetes/manifests/etcd.yaml
- Update the
hostPath
: For example, if you restored etcd to/root/default.etcd
:
- hostPath:
path: /root/default.etcd
type: DirectoryOrCreate
name: etcd-data
Verification
After updating the manifest:
- Check the etcd pod status:
k get pods -n kube-system
- Confirm the etcd logs for successful startup:
k logs etcd-controlplane -n kube-system
- Validate the etcd health:
ETCDCTL_API=3 etcdctl endpoint health \
--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
Subscribe to my newsletter
Read articles from Cheedge Lee directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Cheedge Lee
Cheedge Lee
Some blogs are from my previous blogs, even though I have renovated and checked before migration, but there may be still some parts out of date. (https://blog.sina.com.cn/u/1784323047 or https://blog.csdn.net/li_6698230?type=blog, if they're still accessible.)