Difficulty: Intermediate
What role does etcd play in Kubernetes, why is it so critical, and how do you keep it healthy and backed up?
etcd is the distributed key-value store that holds the entire state of a Kubernetes cluster: every Deployment, Pod, Secret, ConfigMap, lease and custom resource. Only the API server reads and writes it, and every other component works off the API server's view of etcd, so if etcd is lost without a backup, the cluster loses its memory of what should be running.
/registry/deployments/shop/checkout, stored as protobuf (or JSON for custom resources).metadata.resourceVersion, which powers optimistic concurrency (a stale update gets a 409 Conflict).Lease objects, which are also stored in etcd.etcd replicates data with the Raft consensus algorithm. One member is the leader; a write is committed only when a majority (quorum) has it on disk.
| Members | Quorum | Failures tolerated |
|---|---|---|
| 1 | 1 | 0 |
| 3 | 2 | 1 |
| 5 | 3 | 2 |
Even numbers add cost without adding fault tolerance (4 members still tolerate only 1 failure), so production clusters run 3 or 5 members spread across availability zones. If quorum is lost, the API server cannot write. Already running Pods keep running, because kubelets and containers do not need etcd moment to moment, but nothing new can be scheduled, scaled or healed.
wal_fsync_duration and backend_commit_duration metrics.--quota-backend-bytes). If it is exceeded, etcd raises a NOSPACE alarm and rejects writes. Kubernetes compacts old revisions automatically, but you may still need periodic defragmentation to reclaim disk space.EncryptionConfiguration, ideally using a KMS provider. Anyone with etcd access effectively has every Secret in the cluster.On self-managed clusters (kubeadm, bare metal) you must back up etcd yourself, typically with a scheduled etcdctl snapshot save copied off the node. Restore is done with etcdutl snapshot restore into a fresh data directory (the older etcdctl snapshot restore is deprecated), then the etcd static Pod is pointed at it. On EKS, GKE and AKS, the provider runs and backs up etcd for you, but you still want application-level backups with a tool like Velero, because you cannot restore a single namespace from a provider-managed etcd.
export ETCDCTL_API=3
CERTS="--cacert=/etc/kubernetes/pki/etcd/ca.crt \
--cert=/etc/kubernetes/pki/etcd/server.crt \
--key=/etc/kubernetes/pki/etcd/server.key \
--endpoints=https://127.0.0.1:2379"
# Health and status (leader, DB size, raft term)
etcdctl $CERTS endpoint health
etcdctl $CERTS endpoint status --write-out=table
# Take a snapshot
etcdctl $CERTS snapshot save /backup/etcd-$(date +%F).db
etcdutl snapshot status /backup/etcd-$(date +%F).db --write-out=table
# Restore into a new data dir, then point the etcd static Pod at it
etcdutl snapshot restore /backup/etcd-2026-10-12.db \
--data-dir /var/lib/etcd-restore
Snapshots need the etcd client certificates. After restoring, update the hostPath in /etc/kubernetes/manifests/etcd.yaml to the new data directory.
etcd, Raft Consensus, Quorum, Watch API, Backup and Restore