Home DevOps etcd Operations for Kubernetes — Backup, Restore, Tuning
Advanced 5 min · July 12, 2026

etcd Operations for Kubernetes — Backup, Restore, Tuning

Learn etcd Operations for Kubernetes — Backup, Restore, Tuning with plain-English explanations and real examples..

N
Naren Founder & Principal Engineer

20+ years shipping production infrastructure and CI/CD at scale. Lessons pulled from things that broke in production.

Follow
Verified
production tested
July 12, 2026
last updated
2,073
articles · all by Naren
Before you start⏱ 30 min
  • Running Kubernetes cluster (v1.24+), etcdctl (v3.5+), access to etcd certificates (ca.crt, server.crt, server.key), basic understanding of Kubernetes architecture, familiarity with Linux command line and systemd.
✦ Definition~90s read
What is etcd Operations for Kubernetes?

etcd is the distributed key-value store that backs Kubernetes, storing all cluster state and configuration. It is the single source of truth for your cluster — if etcd goes down, your cluster goes blind. Mastering etcd operations is critical for production Kubernetes because a corrupted or lost etcd cluster means total cluster failure.

Think of etcd Operations for Kubernetes — Backup, Restore, Tuning like a tool in your DevOps toolkit — once you understand what it does and when to reach for it, managing Kubernetes clusters becomes second nature.

You need these skills when designing disaster recovery plans, migrating clusters, or scaling etcd for large workloads.

Plain-English First

Think of etcd Operations for Kubernetes — Backup, Restore, Tuning like a tool in your DevOps toolkit — once you understand what it does and when to reach for it, managing Kubernetes clusters becomes second nature.

Welcome to etcd Operations for Kubernetes — Backup, Restore, Tuning. We'll break this down from first principles.

Understanding etcd's Role in Kubernetes

etcd is the brain of Kubernetes. Every kubectl command, every pod scheduling decision, every API object — it all ends up as a key-value pair in etcd. The Kubernetes API server is the only component that talks to etcd directly; all other components go through the API server. This architecture means that etcd's health directly impacts cluster responsiveness and reliability. In production, etcd failures manifest as API server timeouts, node heartbeat loss, and eventual cluster unavailability. Understanding etcd's internal data model — hierarchical keys with leases and watch mechanisms — is essential for debugging and performance tuning. The default etcd deployment in Kubernetes uses a 3-node cluster for high availability, but many operators underestimate the operational complexity of maintaining quorum and handling network partitions.

check-etcd-health.shBASH
1
2
3
4
5
6
7
#!/bin/bash
# Check etcd cluster health
ETCDCTL_API=3 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 health --cluster
Output
https://127.0.0.1:2379 is healthy: successfully committed proposal: took = 2.345ms
https://10.0.0.2:2379 is healthy: successfully committed proposal: took = 3.012ms
https://10.0.0.3:2379 is healthy: successfully committed proposal: took = 1.987ms
⚠ Certificate Paths Vary
The certificate paths shown assume a kubeadm-deployed cluster. For managed Kubernetes (EKS, AKS, GKE), etcd is often abstracted away. Always verify your etcd endpoint and cert locations with kubectl -n kube-system get pods -l component=etcd.
📊 Production Insight
In a real incident, a network partition caused one etcd member to fall behind on writes. When it rejoined, it had to replay the entire raft log, causing a 5-minute API server outage. Always monitor etcd's raft term and applied index.
🎯 Key Takeaway
etcd is the single source of truth for Kubernetes; its failure means cluster failure.

etcd Backup Strategies: Snapshot vs. Streaming

Backing up etcd is non-negotiable. There are two primary methods: snapshot-based and streaming (e.g., Velero). Snapshots capture the entire etcd data store at a point in time and are the most reliable for disaster recovery. The etcdctl snapshot save command creates a consistent snapshot by coordinating with the raft consensus. Streaming backups, while useful for continuous protection, introduce complexity because they must capture every write and can miss state if the backup process lags. For production, always take periodic snapshots (e.g., every 2 hours) and store them off-cluster. Never rely solely on streaming backups for etcd. The snapshot file is a single file that can be restored on any etcd version that is compatible (same major.minor). Always test your restore process in a non-production environment before you need it.

etcd-snapshot.shBASH
1
2
3
4
5
6
7
8
9
10
#!/bin/bash
# Create etcd snapshot
ETCDCTL_API=3 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 \
  snapshot save /backup/etcd-snapshot-$(date +%Y%m%d-%H%M%S).db

# Verify snapshot integrity
ETCDCTL_API=3 etcdctl --write-out=table snapshot status /backup/etcd-snapshot-*.db
Output
+----------+----------+------------+------------+
| HASH | REVISION | TOTAL KEYS | TOTAL SIZE |
+----------+----------+------------+------------+
| abc123 | 1234567 | 98765 | 234 MB |
+----------+----------+------------+------------+
💡Automate Snapshot Rotation
Use a cron job to take snapshots and retain only the last 24 hours locally, plus push a copy to S3/GCS for long-term retention. Example: 0 /2 /usr/local/bin/etcd-snapshot.sh && aws s3 cp /backup/*.db s3://my-bucket/etcd-backups/
📊 Production Insight
We once had a snapshot that appeared valid but was silently corrupted due to disk I/O errors during save. Always run snapshot status immediately after creation and compare the hash with a known good backup.
🎯 Key Takeaway
Snapshot-based backups are the gold standard for etcd disaster recovery.
etcd-kubernetes-operations THECODEFORGE.IO etcd Backup and Restore Workflow Step-by-step process for snapshot backup and restoration Create Snapshot Use etcdctl snapshot save to capture data Verify Snapshot Check snapshot integrity with etcdctl snapshot status Stop etcd Service Halt etcd to prevent data changes Restore Snapshot Use etcdctl snapshot restore to a new data directory Start etcd Service Launch etcd with restored data directory Verify Cluster Health Check member list and endpoint status ⚠ Restoring on a live cluster can cause data inconsistency Always stop etcd before restoring a snapshot THECODEFORGE.IO
thecodeforge.io
Etcd Kubernetes Operations

Restoring etcd from Snapshot

Restoring etcd from a snapshot is a controlled process that requires stopping all etcd members, restoring data, and restarting with a fresh cluster. The key command is etcdctl snapshot restore, which creates a new data directory from the snapshot file. You must restore on a single node first, then add other members as new nodes. Never attempt to restore a snapshot onto an existing etcd member — it will refuse because the cluster ID and member ID don't match. The restore process resets the cluster ID, so all other members must be re-added. After restore, verify that the API server can connect and that all Kubernetes objects are present. Common pitfalls: using the wrong snapshot file (e.g., from a different cluster), mismatched etcd versions, and forgetting to update the etcd member's initial-cluster flag.

etcd-restore.shBASH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
# Stop etcd (systemd example)
systemctl stop etcd

# Restore snapshot to a new data directory
ETCDCTL_API=3 etcdctl snapshot restore /backup/etcd-snapshot-20260712-120000.db \
  --name etcd-0 \
  --initial-cluster etcd-0=https://10.0.0.1:2380 \
  --initial-cluster-token etcd-cluster-1 \
  --initial-advertise-peer-urls https://10.0.0.1:2380 \
  --data-dir /var/lib/etcd-restored

# Move restored data into place
mv /var/lib/etcd /var/lib/etcd.old
mv /var/lib/etcd-restored /var/lib/etcd

# Start etcd
systemctl start etcd

# Verify health
ETCDCTL_API=3 etcdctl endpoint health
Output
https://10.0.0.1:2379 is healthy: successfully committed proposal: took = 1.234ms
⚠ Cluster Token Must Be Unique
The --initial-cluster-token must be different from any previous cluster token. If you reuse the same token, etcd may refuse to form a cluster. Use a unique string per restore.
📊 Production Insight
During a restore drill, we forgot to update the --initial-cluster flag on the second node, causing a split-brain scenario. Always double-check the initial cluster configuration on every member.
🎯 Key Takeaway
Restore is a single-node operation; re-add other members as new nodes.

etcd Performance Tuning: Disk I/O and Network

etcd is I/O sensitive. The single most important performance factor is disk latency — etcd requires a high-performance SSD with low p99 latency (under 10ms). Use dedicated disks for etcd data and WAL (write-ahead log) to avoid contention with other workloads. The etcd --fsync duration is a critical metric: if it exceeds 100ms, you risk raft election timeouts. Network latency between etcd members should be under 10ms round-trip; deploy all members in the same availability zone if possible. Tune the --heartbeat-interval (default 100ms) and --election-timeout (default 1000ms) for your network conditions. For large clusters (over 1000 nodes), increase --quota-backend-bytes to 8GB or more to handle the increased key count. Monitor etcd's db size — if it exceeds the quota, etcd will stop accepting writes.

etcd-performance-config.yamlYAML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# etcd configuration for high-performance
# Place in /etc/etcd/etcd.conf
name: 'etcd-0'
data-dir: /var/lib/etcd
wal-dir: /var/lib/etcd/wal
listen-client-urls: https://0.0.0.0:2379
listen-peer-urls: https://0.0.0.0:2380
initial-cluster: 'etcd-0=https://10.0.0.1:2380,etcd-1=https://10.0.0.2:2380,etcd-2=https://10.0.0.3:2380'
initial-cluster-state: new
heartbeat-interval: 100
election-timeout: 1000
quota-backend-bytes: 8589934592  # 8 GB
max-request-bytes: 1572864  # 1.5 MB
auto-compaction-mode: periodic
auto-compaction-retention: '1h'
🔥Disk Benchmarking
Before deploying etcd, benchmark your disk with fio to ensure it meets the 99th percentile fsync latency under 10ms. Example: fio --name=etcd-test --ioengine=sync --rw=write --bs=4k --numjobs=1 --size=256m --runtime=60 --direct=1
📊 Production Insight
We saw periodic etcd latency spikes traced to a shared EBS volume with a noisy neighbor. Moving etcd to a provisioned IOPS volume eliminated the issue.
🎯 Key Takeaway
Disk latency is the #1 bottleneck for etcd performance.

etcd Compaction and Defragmentation

etcd compacts history periodically to free up space. By default, Kubernetes enables auto-compaction with a retention of 1 hour. However, compaction only marks space as free; it does not reclaim it. Over time, the etcd database file grows due to fragmentation. Defragmentation (etcdctl defrag) reclaims this space and should be run periodically (e.g., daily) on each member. Defrag is a blocking operation — it stops serving requests on that member while running. In a multi-member cluster, you can defrag one member at a time without downtime. Monitor the db size via metrics; if it approaches the quota, defrag immediately. For clusters with heavy churn (e.g., frequent pod creations/deletions), consider increasing compaction retention or running defrag more often.

etcd-defrag.shBASH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#!/bin/bash
# Defragment etcd member (run on each member sequentially)
ETCDCTL_API=3 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 \
  defrag

# Check db size after defrag
ETCDCTL_API=3 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 status --write-out=table | awk '{print $4}'
Output
234 MB
💡Schedule Defrag During Low Traffic
Run defrag during maintenance windows or low-traffic periods. Use a cron job that checks the current leader and defrags followers first, then the leader last.
📊 Production Insight
We once had an etcd member run out of disk because defrag hadn't been run in weeks. The member went offline, causing a quorum loss and a 10-minute cluster outage. Now we defrag daily.
🎯 Key Takeaway
Defrag is necessary to reclaim disk space after compaction.

Monitoring etcd Health and Metrics

etcd exposes Prometheus metrics on the client port (2379). Key metrics to monitor: etcd_server_has_leader (should be 1), etcd_server_leader_changes_seen_total (should be low), etcd_disk_wal_fsync_duration_seconds_bucket (p99 < 10ms), etcd_network_client_grpc_sent_bytes_total (traffic volume), and etcd_mvcc_db_total_size_in_bytes (db size). Set up alerts for: no leader for >10 seconds, high fsync latency, db size >80% of quota, and frequent leader changes. Use etcdctl endpoint status and etcdctl endpoint health for quick checks. Integrate with your monitoring stack (Prometheus + Grafana) for historical trends. A common pitfall is monitoring only the local etcd member — always check all members from an external perspective.

etcd-alerts.promqlPROMQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Alert: etcd no leader
alert: EtcdNoLeader
expr: etcd_server_has_leader == 0
for: 1m
labels:
  severity: critical
annotations:
  summary: "etcd cluster has no leader"

# Alert: high fsync latency
alert: EtcdHighFsyncLatency
expr: histogram_quantile(0.99, rate(etcd_disk_wal_fsync_duration_seconds_bucket[5m])) > 0.1
for: 5m
labels:
  severity: warning
annotations:
  summary: "etcd WAL fsync latency is high"

# Alert: db size approaching quota
alert: EtcdDbSizeHigh
expr: etcd_mvcc_db_total_size_in_bytes / etcd_server_quota_backend_bytes > 0.8
for: 10m
labels:
  severity: warning
annotations:
  summary: "etcd db size is above 80% of quota"
🔥Grafana Dashboard
Use the official etcd Grafana dashboard (ID: 3070) for a comprehensive view. It includes panels for raft proposals, disk latency, and network traffic.
📊 Production Insight
A sudden spike in leader changes was the first sign of a network issue between availability zones. We moved all etcd members to the same AZ and the problem disappeared.
🎯 Key Takeaway
Monitor etcd's leader, fsync latency, and db size to catch issues early.

etcd Security: TLS and Authentication

etcd supports TLS for client-to-server and peer-to-peer communication, as well as username/password authentication. In Kubernetes, etcd is typically deployed with TLS certificates issued by the cluster's CA. Never expose etcd's client port (2379) to the public internet. Use firewall rules to restrict access to only the API server nodes. Enable client certificate authentication to ensure only the API server can connect. For peer communication, use separate certificates to prevent unauthorized nodes from joining the cluster. Rotate certificates before they expire — expired certificates cause immediate cluster failure. Use etcdctl with --cacert, --cert, and --key flags for secure access. For additional security, enable role-based access control (RBAC) on etcd itself, though this is rarely needed in Kubernetes contexts.

etcd-tls-check.shBASH
1
2
3
4
5
6
7
8
9
10
#!/bin/bash
# Verify TLS certificates
openssl x509 -in /etc/kubernetes/pki/etcd/server.crt -text -noout | grep -E 'Subject:|Not After'

# Test TLS connection
ETCDCTL_API=3 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 health
Output
Subject: CN = etcd-server
Not After : Jul 12 2027 12:00:00 GMT
https://127.0.0.1:2379 is healthy
⚠ Certificate Expiry
Set up monitoring for certificate expiry. Use kubeadm alpha certs check-expiration or a Prometheus exporter like cert_exporter to alert 30 days before expiry.
📊 Production Insight
We had a cluster outage because the etcd peer certificate expired during a rolling update. The new member couldn't join, and we lost quorum. Now we automate certificate renewal with cert-manager.
🎯 Key Takeaway
TLS is mandatory for production etcd; never expose ports without encryption.
etcd-kubernetes-operations THECODEFORGE.IO etcd Cluster Architecture Layers Component hierarchy for a production etcd deployment Application Layer Kubernetes API Server | etcdctl CLI Client Interface gRPC API | v3 API Raft Consensus Leader Election | Log Replication Storage Engine BoltDB | MVCC Disk I/O WAL | Snapshot Files Network Layer Peer Communication | Client Requests THECODEFORGE.IO
thecodeforge.io
Etcd Kubernetes Operations

Scaling etcd for Large Clusters

etcd performance degrades as the number of keys and watch clients grows. For clusters with over 1000 nodes, consider tuning: increase --quota-backend-bytes to 8GB or more, reduce --heartbeat-interval to 50ms, and increase --election-timeout to 2000ms to avoid false elections. Use a dedicated etcd cluster with 5 members for better fault tolerance (tolerates 2 failures instead of 1). Avoid putting etcd on the same node as other heavy workloads. For extremely large clusters (5000+ nodes), consider using a separate etcd cluster for events only (via --etcd-servers-overrides). Monitor the number of watchers — each pod and controller creates watches. If watchers exceed 10000, consider using a more efficient watch mechanism or sharding.

etcd-large-cluster-config.yamlYAML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# etcd configuration for large clusters
name: 'etcd-0'
data-dir: /var/lib/etcd
wal-dir: /var/lib/etcd/wal
listen-client-urls: https://0.0.0.0:2379
listen-peer-urls: https://0.0.0.0:2380
initial-cluster: 'etcd-0=https://10.0.0.1:2380,etcd-1=https://10.0.0.2:2380,etcd-2=https://10.0.0.3:2380,etcd-3=https://10.0.0.4:2380,etcd-4=https://10.0.0.5:2380'
initial-cluster-state: new
heartbeat-interval: 50
election-timeout: 2000
quota-backend-bytes: 17179869184  # 16 GB
max-request-bytes: 1572864  # 1.5 MB
auto-compaction-mode: periodic
auto-compaction-retention: '30m'
🔥5-Member Cluster Trade-off
A 5-member cluster tolerates 2 failures but requires a majority of 3 for writes. This increases write latency slightly but improves availability. Use only if you have at least 5 distinct failure domains.
📊 Production Insight
At 2000 nodes, we saw etcd election timeouts because the default heartbeat interval was too short for the network latency between AZs. Increasing to 200ms fixed it.
🎯 Key Takeaway
For large clusters, tune heartbeat intervals and increase member count to 5.

Disaster Recovery: Full Cluster Restore

A full cluster restore is needed when all etcd members are lost (e.g., entire region failure). The process: provision new etcd nodes, restore the latest snapshot on one node, start it as a single-member cluster, then add other members. After restore, verify that the API server can connect and that all Kubernetes objects are present. If the snapshot is old, you may lose recent changes — always combine with application-level backups. Test your DR plan quarterly. A common mistake is restoring a snapshot from a different cluster (different cluster ID) — etcd will refuse to start. Use etcdctl snapshot status to verify the snapshot's cluster ID matches your backup records. Document the exact steps and practice them in a staging environment.

etcd-full-restore.shBASH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/bash
# Full cluster restore on new nodes
# Step 1: Restore on first node
ETCDCTL_API=3 etcdctl snapshot restore /backup/etcd-snapshot-latest.db \
  --name etcd-0 \
  --initial-cluster etcd-0=https://10.0.0.1:2380 \
  --initial-cluster-token etcd-cluster-restore \
  --initial-advertise-peer-urls https://10.0.0.1:2380 \
  --data-dir /var/lib/etcd

# Start etcd on node 1
systemctl start etcd

# Step 2: On node 2, restore with different name
ETCDCTL_API=3 etcdctl snapshot restore /backup/etcd-snapshot-latest.db \
  --name etcd-1 \
  --initial-cluster etcd-0=https://10.0.0.1:2380,etcd-1=https://10.0.0.2:2380 \
  --initial-cluster-token etcd-cluster-restore \
  --initial-advertise-peer-urls https://10.0.0.2:2380 \
  --data-dir /var/lib/etcd

# Start etcd on node 2
systemctl start etcd

# Repeat for node 3...

# Verify cluster health
ETCDCTL_API=3 etcdctl --endpoints=https://10.0.0.1:2379,https://10.0.0.2:2379,https://10.0.0.3:2379 \
  --cacert=/etc/kubernetes/pki/etcd/ca.crt \
  --cert=/etc/kubernetes/pki/etcd/server.crt \
  --key=/etc/kubernetes/pki/etcd/server.key \
  endpoint health --cluster
Output
https://10.0.0.1:2379 is healthy
https://10.0.0.2:2379 is healthy
https://10.0.0.3:2379 is healthy
⚠ Same Snapshot, Same Token
All members must use the same snapshot file and the same --initial-cluster-token. Using different snapshots will result in data inconsistency.
📊 Production Insight
During a DR drill, we discovered that our snapshot was 6 hours old because the backup cron job had failed silently. Now we monitor backup success with a separate alert.
🎯 Key Takeaway
Test your DR plan quarterly; a full restore is a multi-step process.

etcd Operator and Automation

For large-scale deployments, consider using the etcd Operator (from CoreOS) to automate cluster management. The operator handles backups, restores, scaling, and upgrades. It uses Custom Resource Definitions (CRDs) to define etcd clusters. However, the operator adds complexity and is not recommended for small clusters. For Kubernetes clusters managed by kubeadm, the static pod approach is simpler. If you use the operator, ensure you understand its backup and restore mechanisms — they differ from manual etcdctl commands. The operator can also automate defragmentation and compaction. Always test operator upgrades in a staging environment first.

etcd-cluster-crd.yamlYAML
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
apiVersion: etcd.database.coreos.com/v1beta2
kind: EtcdCluster
metadata:
  name: my-etcd-cluster
spec:
  size: 3
  version: 3.5.9
  pod:
    resources:
      requests:
        cpu: 200m
        memory: 512Mi
      limits:
        cpu: 500m
        memory: 1Gi
    etcdEnv:
      - name: ETCD_AUTO_COMPACTION_RETENTION
        value: '1h'
💡Operator Version Compatibility
Ensure the operator version matches your etcd version. Check the operator's release notes for supported etcd versions.
📊 Production Insight
We used the operator for a year but switched back to static pods after an operator upgrade caused a cluster outage. The operator is powerful but requires careful version management.
🎯 Key Takeaway
The etcd Operator automates cluster management but adds complexity.

Common etcd Failure Modes and Mitigations

etcd failures often stem from disk latency, network partitions, or misconfiguration. Common failure modes: (1) Disk full — etcd stops accepting writes. Mitigation: monitor disk usage and set up alerts. (2) Network partition — a minority of members become isolated, causing leader election failure. Mitigation: deploy all members in the same AZ or use a 5-member cluster. (3) Slow disk — fsync latency exceeds election timeout, causing frequent leader changes. Mitigation: use dedicated SSDs with provisioned IOPS. (4) Certificate expiry — members cannot communicate. Mitigation: automate certificate renewal. (5) Quota exceeded — etcd stops writes. Mitigation: increase quota or defrag. (6) Raft log corruption — rare but catastrophic. Mitigation: regular backups and restore drills. Each failure mode should have a documented runbook.

etcd-disk-check.shBASH
1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
# Check disk latency and space
echo "Disk latency (fsync):"
ETCDCTL_API=3 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 status --write-out=table | awk '{print $6}'

echo "Disk usage:"
df -h /var/lib/etcd
Output
Disk latency (fsync):
2.345ms
Disk usage:
Filesystem Size Used Avail Use% Mounted on
/dev/nvme0n1 50G 12G 38G 24% /var/lib/etcd
⚠ Runbook Required
Document each failure mode and its recovery steps. Include commands, expected outputs, and escalation paths. Practice the runbook quarterly.
📊 Production Insight
We had a disk full incident that took down the cluster for 20 minutes because no one knew how to safely free space. Now we have a runbook that includes deleting old snapshots and running defrag.
🎯 Key Takeaway
Know the common failure modes and have a runbook for each.
Snapshot vs Streaming Backup Trade-offs between snapshot and streaming backup strategies Snapshot Backup Streaming Backup Data Consistency Point-in-time consistent Near real-time, may lag Storage Overhead Full copy each time Incremental changes only Restore Speed Fast, single file restore Requires replay of logs Network Usage Bursty, high bandwidth Steady, lower bandwidth Complexity Simple, one command Requires pipeline setup Use Case Disaster recovery Continuous backup THECODEFORGE.IO
thecodeforge.io
Etcd Kubernetes Operations

etcd Version Upgrades

Upgrading etcd requires careful planning. Always upgrade one minor version at a time (e.g., 3.4 to 3.5, not 3.4 to 3.6). The Kubernetes API server must be compatible with the etcd version — check the Kubernetes release notes for supported etcd versions. The upgrade process: (1) Take a snapshot. (2) Upgrade one member at a time: stop etcd, replace binary, start etcd. (3) Verify cluster health after each member. (4) After all members are upgraded, verify API server connectivity. Rolling upgrades are safe because etcd supports mixed-version clusters during the upgrade window. However, avoid making configuration changes during the upgrade. Downgrades are not supported — if an upgrade fails, restore from snapshot.

etcd-upgrade.shBASH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
# Upgrade etcd on a single member
# 1. Take snapshot
ETCDCTL_API=3 etcdctl snapshot save /backup/pre-upgrade-snapshot.db

# 2. Stop etcd
systemctl stop etcd

# 3. Replace binary
cp /usr/local/bin/etcd /usr/local/bin/etcd.old
cp /tmp/etcd-v3.5.9-linux-amd64/etcd /usr/local/bin/etcd

# 4. Start etcd
systemctl start etcd

# 5. Verify health
ETCDCTL_API=3 etcdctl endpoint health

# Repeat on other members
Output
https://127.0.0.1:2379 is healthy
🔥Kubernetes Compatibility
Check the Kubernetes version's supported etcd versions: kubectl version --short shows the server version, then refer to the Kubernetes release notes for the compatible etcd range.
📊 Production Insight
We once upgraded etcd from 3.4 to 3.5 and the API server crashed because it was still using an old client library. Always upgrade the API server first or ensure compatibility.
🎯 Key Takeaway
Upgrade one minor version at a time, one member at a time.
⚙ Quick Reference
12 commands from this guide
FileCommand / CodePurpose
check-etcd-health.shETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \Understanding etcd's Role in Kubernetes
etcd-snapshot.shETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \etcd Backup Strategies
etcd-restore.shsystemctl stop etcdRestoring etcd from Snapshot
etcd-performance-config.yamlname: 'etcd-0'etcd Performance Tuning
etcd-defrag.shETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 \etcd Compaction and Defragmentation
etcd-alerts.promqlalert: EtcdNoLeaderMonitoring etcd Health and Metrics
etcd-tls-check.shopenssl x509 -in /etc/kubernetes/pki/etcd/server.crt -text -noout | grep -E 'Sub...etcd Security
etcd-large-cluster-config.yamlname: 'etcd-0'Scaling etcd for Large Clusters
etcd-full-restore.shETCDCTL_API=3 etcdctl snapshot restore /backup/etcd-snapshot-latest.db \Disaster Recovery
etcd-cluster-crd.yamlapiVersion: etcd.database.coreos.com/v1beta2etcd Operator and Automation
etcd-disk-check.shecho "Disk latency (fsync):"Common etcd Failure Modes and Mitigations
etcd-upgrade.shETCDCTL_API=3 etcdctl snapshot save /backup/pre-upgrade-snapshot.dbetcd Version Upgrades

Key takeaways

1
etcd is the single source of truth
Backup and restore procedures are critical for cluster survival.
2
Disk latency is the #1 performance bottleneck
Use dedicated SSDs and monitor fsync latency.
3
Defragmentation is mandatory
Compaction alone does not reclaim disk space; schedule defrag regularly.
4
Test your disaster recovery plan quarterly
A backup is only as good as its restore; practice the process.
INTERVIEW PREP · PRACTICE MODE

Interview Questions on This Topic

Q01JUNIOR
How do I take a backup of etcd in a Kubernetes cluster?
Q02JUNIOR
What is the difference between compaction and defragmentation in etcd?
Q03JUNIOR
Can I restore an etcd snapshot to a cluster with a different number of m...
Q01 of 03JUNIOR

How do I take a backup of etcd in a Kubernetes cluster?

ANSWER
Use etcdctl snapshot save with the appropriate endpoints and certificates. For kubeadm clusters, the command is: `ETCDCTL_API=3 etcdctl --endpoints=https://127.0.0.1:2379 --cacert=/etc/kubernetes/pk
FAQ · 6 QUESTIONS

Frequently Asked Questions

01
How do I take a backup of etcd in a Kubernetes cluster?
02
What is the difference between compaction and defragmentation in etcd?
03
Can I restore an etcd snapshot to a cluster with a different number of members?
04
What happens if etcd runs out of disk space?
05
How do I monitor etcd performance in production?
06
Should I use a 3-node or 5-node etcd cluster?
N
Naren Founder & Principal Engineer

20+ years shipping production infrastructure and CI/CD at scale. Lessons pulled from things that broke in production.

Follow
Verified
production tested
July 12, 2026
last updated
2,073
articles · all by Naren
🔥

That's Kubernetes. Mark it forged?

5 min read · try the examples if you haven't

Previous
Kubernetes Pod Priority and Preemption
23 / 38 · Kubernetes
Next
Kubernetes Ingress Controllers — NGINX, Traefik, AWS ALB