Etcd Backup and Restore (4)

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