A quick reference for etcdctl โ the etcd command-line client. Bookmark this page.
This is a companion to the etcd Cheat Sheet, focused on etcdctl commands specifically for Kubernetes cluster administration.
Setup
# Set API version (always use v3)
export ETCDCTL_API=3
# For Kubernetes clusters
export ETCDCTL_ENDPOINTS=https://127.0.0.1:2379
export ETCDCTL_CACERT=/etc/kubernetes/pki/etcd/ca.crt
export ETCDCTL_CERT=/etc/kubernetes/pki/etcd/server.crt
export ETCDCTL_KEY=/etc/kubernetes/pki/etcd/server.key
# Or pass inline
etcdctl --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 \
endpoint healthHealth and Status
etcdctl endpoint health
etcdctl endpoint health --cluster
etcdctl endpoint status --write-out=table
etcdctl member list --write-out=tableBackup and Restore
# Backup
etcdctl snapshot save /backup/etcd-$(date +%Y%m%d-%H%M).db
# Verify backup
etcdctl snapshot status /backup/etcd-20260413.db --write-out=table
# Restore (stop etcd first!)
etcdctl snapshot restore /backup/etcd-20260413.db \
--data-dir=/var/lib/etcd-restoredKey Operations
etcdctl get / --prefix --keys-only | head -20
etcdctl get /registry/pods/default --prefix --keys-only
etcdctl get /registry/deployments --prefix --keys-only | wc -lMaintenance
# Check DB size
etcdctl endpoint status --write-out=json | python3 -m json.tool
# Compact and defrag
rev=$(etcdctl endpoint status --write-out=json | python3 -c "import sys,json; print(json.load(sys.stdin)[0]['Status']['header']['revision'])")
etcdctl compact $rev
etcdctl defrag --clusterTips and Tricks
- Schedule daily etcd backups โ it is the single source of truth for your cluster
- Monitor etcd disk latency:
etcdctl check perf - Use
--write-out=tablefor human-readable output - Keep etcd data on fast SSD/NVMe storage
- Set alarms:
etcdctl alarm listandetcdctl alarm disarm