An etcd Snapshot Alone Can't Rebuild a kubeadm Control Plane, So Back Up the PKI with It

In progress Kubernetes

An etcd snapshot holds every API object: Deployments, Services, ConfigMaps, Secrets, Nodes, RBAC. It does not hold the keys that make the cluster trust itself. kubeadm keeps those as files on the control plane, in /etc/kubernetes/pki:

File Signs or proves Lost and regenerated means
ca.key / ca.crt every kubelet, admin and component certificate every kubeconfig and every node's kubelet stops trusting the API: nodes rejoin, kubeconfigs are reissued
etcd/ca.key etcd's server and peer certificates the restored etcd can't be reached by the API server with the old client certs
sa.key / sa.pub ServiceAccount tokens every token already mounted in a pod is rejected
front-proxy-ca.key the aggregation layer (metrics-server and other API extensions) extension APIs fail authentication

So restoring a snapshot onto a rebuilt machine with freshly generated certificates gives back the objects, but none of the trust around them. Back up the PKI directory with the snapshot, as one bundle, and treat the bundle as a secret: whoever holds ca.key can mint a cluster-admin certificate.

What a Restore Needs

  • Same identity: same hostname, IP and VIP, so the member name and peer URL in the etcd manifest still match (see kubeadm Uses the Hostname as the Node Name, So Name a Node Before It Joins).
  • The PKI back in place before etcd and the API server start, then the snapshot restored into the data directory with etcdutl snapshot restore.
  • Revisions moved forward: controllers and watchers cache the last revision they saw, which can be newer than the snapshot. etcd 3.6's etcdutl can --bump-revision and --mark-compacted, which forces them to re-list instead of trusting stale caches; restart controllers that still misbehave.
  • Anything written after the snapshot is gone, so the snapshot interval is the cluster's recovery point objective.

A Backup Counts Once a Restore Works

A snapshot file can be truncated or written from an unhealthy member. etcdutl snapshot status only reports its hash, revision and key count, and etcdutl snapshot restore checks the integrity hash that etcdctl snapshot save appended, but only a restore you actually run proves the backup works: restore it into a throwaway etcd on another port, read it, and compare the key counts with the live one. That drill never touches the running cluster, so it can run on a schedule.

High availability doesn't replace any of this: three members replicate a mistaken delete as faithfully as a good write (see Two etcd Members Tolerate No More Failures Than One, So Go from One Control Plane to Three).

References

Review cards

Flashcard Why can't an etcd snapshot alone rebuild a kubeadm control plane on a new machine?

It holds the API objects but not /etc/kubernetes/pki. New CA and ServiceAccount keys mean nodes, kubeconfigs and pod tokens no longer trust the cluster.

Quiz After restoring etcd with a newly generated `sa.key`, what breaks first?
  • The etcd member can't start
  • ServiceAccount tokens already mounted in pods are rejected
  • Deployments disappear from the API
  • The kube-vip address moves to another node

sa.key signs ServiceAccount tokens; a new key invalidates every token signed with the old one.

Flashcard Why restore a snapshot into a throwaway etcd on a schedule?

A file that exists isn't a backup until it restores. A drill on another port proves it without touching the live cluster.