etcd: quorum, Raft, and the failure modes that page you

Majority quorum: 3 tolerate 1, 5 tolerate 2, even numbers add cost and no tolerance. Lose quorum and writes stop by design — and disk latency is etcd's health.

Read the briefing
About 9 min to read 8 drills

What to remember

  1. 3 or 5 members, never 4. Majority of 4 is 3, so it tolerates the same single failure as 3 members while making partitions likelier.
  2. Lost quorum stops writes on purpose. Consistency over availability. Reads may still be served; nothing new is scheduled.
  3. etcd lives or dies by disk fsync latency. Put it on fast local NVMe and alert on wal_fsync_duration percentiles.
  4. Every object counts, including Secrets and ConfigMaps. Object-count quotas exist to stop one operator bloating the store.
  5. A backup you have not restored is not a backup. Practise the restore, and know your cluster's rebuild time.

The big picture

etcd is the only stateful component of the control plane: every object the API server serves is a key in a Raft-replicated key-value store, and the API server is its only client. Its failure modes are the ones that take a whole cluster's control plane down at once: quorum loss when members die together, leader churn and timeouts from slow disks, and a NOSPACE alarm that refuses every write. Interviewers use etcd to test whether you reason from the majority rule and from durability mechanics rather than from memorized numbers.

The mental model

Picture a replicated append-only log with one leader. Every write goes to the leader, is fsynced to the write-ahead log on a majority of members, and only then is acknowledged; the key-value store is just that log applied in order, with every historical revision kept until compaction. Availability is therefore a function of two things: can a strict majority of members still talk to each other, and can each member fsync fast enough to keep heartbeats and commits flowing. Lose the majority and the control plane freezes while the data plane keeps running; lose disk latency and the cluster flaps between leaders.

In depth

What etcd holds and who talks to it

Every Kubernetes object is a key under /registry/<resource>/<namespace>/<name> (/registry/pods/shop/checkout-7c9d-2xk4p), stored as protobuf. Secrets are stored as written unless encryption at rest is configured through an EncryptionConfiguration, which is why "base64 is not encryption" and why etcd snapshots must be protected like credentials. The API server is the only client: it speaks mTLS to client port 2379, members replicate over peer port 2380, and no controller, kubelet, or kubectl ever holds an etcd certificate. The API server's own watch mechanism is built on etcd watches, so etcd's revision history is where resourceVersion comes from.

Two limits leak into everyday Kubernetes. A single request is capped at about 1.5 MiB, so a ConfigMap or CRD object beyond that fails with etcdserver: request is too large. And every write, including status updates and Events, is a revision, so churny writers (Events above all) are why large clusters point Events at a separate etcd with --etcd-servers-overrides=/events#https://....

On kubeadm clusters etcd runs as a static pod from /etc/kubernetes/manifests/etcd.yaml with data in /var/lib/etcd, one member per control-plane node. etcdctl endpoint status -w table --cluster shows each member's ID, version, DB size, leader flag, Raft term, and index; etcdctl endpoint health --cluster is the first health check. Managed clusters hide etcd, but its symptoms still surface as API server latency, Unable to connect to the server, or writes failing with etcdserver: request timed out, so the mechanics matter even when you cannot log in to it.

Raft in one paragraph: leader, log, majority

etcd members elect a leader for a numbered term. The leader sends heartbeats every --heartbeat-interval (100 ms by default); a follower that hears nothing for --election-timeout (1000 ms by default) starts an election, and the candidate with the most up-to-date log that gathers a majority of votes wins. Writes go through the leader only: it appends the entry to its write-ahead log, replicates it to followers, and commits once a majority (itself included) has fsynced it, then applies it to the key-value store and acknowledges the client. A follower that missed entries catches up from the leader's log or, if too far behind, from a snapshot of the store.

Reads are linearizable by default: the leader confirms it is still leader (ReadIndex) before answering, so a read never returns stale data even during a partition. The API server uses these quorum reads, which is why reads also fail when quorum is lost. etcdctl get --consistency=s asks a single member for its local state and can be stale; that is a debugging tool, not what Kubernetes does.

The Raft picture explains the two operational numbers you tune together: heartbeat interval roughly equal to the round-trip time between members, election timeout about ten times the heartbeat. Stretch members across regions with 30 ms round trips and every commit pays that latency, while too tight a timeout produces spurious elections on every network hiccup. etcd_server_leader_changes_seen_total rising is the metric that says elections are happening; ask why before asking what.

Quorum arithmetic and what losing it looks like

Quorum is a strict majority: floor(n/2) + 1. Three members need two, so one can fail; five need three, so two can fail; seven tolerate three. Four members still need three, so the tolerance is one, the same as three members, with more replication cost. That is the whole argument for odd sizes, and it is the argument interviewers want derived, not recited. Membership changes also need quorum, so you cannot "add a member to restore quorum": the survivors of a lost quorum cannot commit the change. Adding members safely uses a learner (etcdctl member add --learner), which receives the log without voting until it is promoted.

When quorum is lost, the leader steps down, no writes commit, and linearizable reads stop. The API server returns etcdserver: request timed out or leader changed, kubectl reports Unable to connect to the server: EOF or hangs, controllers and the scheduler freeze, kubelets cannot post status. The data plane keeps running: kubelets keep pods alive and probed, kube-proxy keeps its rules. Say that first in any incident; it decides whether customers are affected.

What not to do: --force-new-cluster on a survivor discards the other members' identities and creates a single-member cluster from its data, so if the dead members return you have two clusters with diverging history; and restoring a snapshot onto the survivor rolls the cluster back hours for a problem that a returning rack would have fixed in minutes. The cheapest recovery is almost always to bring the dead members back. Prevention is topology: spread members across racks or zones so no single failure domain holds a majority, alert on etcd_server_has_leader and member health, and rehearse the restore for the day topology was not enough.

Disk latency: the failure mode that pages you

Because every commit waits for fsync on a majority, etcd's write path is bounded by disk latency, not CPU. The two metrics that define health are etcd_disk_wal_fsync_duration_seconds (p99 should stay under about 10 ms) and etcd_disk_backend_commit_duration_seconds (p99 under about 25 ms). When they climb, the leader misses heartbeats, followers start elections, etcd_server_leader_changes_seen_total ticks up, and the logs fill with apply request took too long, slow fdatasync, and waiting for ReadIndex response took too long. The API server, waiting on etcd, times out; kubelets fail to post status and nodes flap NotReady; kubectl becomes intermittently slow with CPU everywhere idle. That signature, idle CPU plus leader churn plus timeouts, is disk.

Usual causes: etcd sharing a disk with container images, logs, or the OS; network-attached volumes whose burst credits run out after a quiet period; noisy neighbours on shared storage; a hypervisor stealing CPU so fsync completion is delayed; or a backup or antivirus agent scanning the data directory. Verify with etcdctl check perf and with the fio recipe from the etcd documentation (synchronous writes with --fdatasync=1 at etcd's 2300-byte block size), and with iostat -x looking at write latency during the incident.

Fixes are physical: a dedicated SSD or NVMe volume for /var/lib/etcd, optionally a separate --wal-dir on its own device, provisioned IOPS rather than burstable storage in the cloud, control-plane nodes that run nothing else, and Events on a separate etcd for large clusters. Snapshot backups also cause latency spikes; schedule them and take them from a follower when you can. The interview tell is a candidate who reaches for "more etcd members" or "bigger CPUs" when the metrics say fsync.

Revisions, compaction, defragmentation, and NOSPACE

etcd is a multi-version store: every write creates a new revision, and old versions of a key are kept so watchers can catch up and clients can read at a point in time. History grows until compaction discards revisions older than a chosen one. The API server drives compaction itself (--etcd-compaction-interval, five minutes by default), and etcd can additionally run it (--auto-compaction-mode=periodic --auto-compaction-retention=1h is a common distribution setting); disabling both turns normal controller churn into unbounded growth. Compaction frees space only logically; the backend file keeps its size until defragmentation (etcdctl defrag --endpoints=<one member>) rewrites it, and defrag blocks that member, so run it one member at a time, off-peak, followers first.

The backend has a quota, --quota-backend-bytes, 2 GiB by default and about 8 GiB as the recommended ceiling. When the file exceeds it, etcd raises the NOSPACE alarm and refuses every write cluster-wide: kubectl create fails with etcdserver: mvcc: database space exceeded while reads keep working. Deleting objects does not help; deletes are new revisions. Recovery is a fixed sequence: read the current revision from etcdctl endpoint status -w json, etcdctl compact <rev>, etcdctl defrag on each member, then etcdctl alarm disarm; disarming first just re-trips the alarm. Then find the churn: compare etcd_mvcc_db_total_size_in_bytes with etcd_mvcc_db_total_size_in_use_in_bytes (a big gap is fragmentation, a small gap is live data) and count keys by resource with etcdctl get / --prefix --keys-only | awk -F/ '{print $3}' | sort | uniq -c | sort -rn to see whether Events, Leases, or a misbehaving controller's status updates are the source. Raise the quota only when the working set genuinely needs it.

Compaction has one visible consequence upstream: a watcher that asks for a compacted revision gets etcdserver: mvcc: required revision has been compacted, which the API server surfaces to clients as too old resource version, and they re-list.

Backup and restore

etcdctl snapshot save backup.db (pointed at one healthy endpoint with the client certificates) writes a consistent point-in-time copy of the backend; etcdutl snapshot status backup.db verifies it and reports revision and size. Take snapshots on a cadence matched to your recovery point objective, before every control-plane upgrade, ship them off the cluster, and encrypt them: they contain every Secret in the cluster in whatever form etcd stored it.

Restore rebuilds members rather than repairing them. For each member you run etcdutl snapshot restore backup.db --name <member> --initial-cluster <all members> --initial-advertise-peer-urls <its peer URL> --initial-cluster-token <new token> --data-dir <new dir>, which creates a fresh data directory with a new cluster ID and member IDs, then start the members on those directories and point the API servers at them. Restore all members from the same snapshot; mixing an old data directory with a restored one produces two clusters.

Consequences follow from "point in time". Everything written after the snapshot is gone from the API: pods created since vanish as objects while their containers keep running until the kubelet removes pods the API no longer knows; objects deleted since reappear and controllers recreate what they imply; resourceVersions go backwards, so restart the API servers, controller-manager, and scheduler and expect a re-list storm as clients recover. Controllers then reconcile the cluster toward the restored desired state, which is exactly what you want and also what will surprise anyone who deployed in the gap.

Prove the plan before you need it: restore into a scratch environment on a schedule, time it against the recovery time objective, and alert on backup age and last successful verification. On managed clusters the provider snapshots etcd for its own recovery and you cannot restore it yourself, so workload-level backups (GitOps repositories, Velero) are your restore story there.

Myths and facts

Myth: Adding etcd members increases write throughput.

Fact: Every write still goes through one leader and waits for a majority of fsyncs; more members mean a larger majority and more replication. Members buy fault tolerance (at odd counts), not write capacity.

Myth: Four members are safer than three.

Fact: Four need three for quorum, so they tolerate one failure, exactly like three. Tolerance increases only at 3, 5, 7.

Myth: If etcd loses quorum the workloads go down.

Fact: The control plane becomes unavailable: no kubectl, no scheduling, no reconciliation. Kubelets keep running and probing existing pods, and kube-proxy keeps routing.

Myth: Deleting Kubernetes objects frees space in etcd.

Fact: Deletes are new revisions. Space is reclaimed only by compaction (logically) followed by defragmentation (physically), and the NOSPACE alarm must be disarmed afterwards.

Myth: Restoring a snapshot puts the cluster back exactly as it was.

Fact: It rolls the whole cluster back to the snapshot's point in time with a new cluster identity; objects created since disappear, deleted ones return, and controllers reconcile toward that older state.

Myth: etcd is slow because the control-plane nodes need more CPU.

Fact: Leader elections and 'apply request took too long' with idle CPU point at disk fsync latency. Check wal_fsync p99 before touching instance sizes.

Myth: Secrets are encrypted in etcd by default.

Fact: They are stored as written unless an EncryptionConfiguration is set; base64 is an encoding. Snapshots therefore contain plaintext secrets unless encryption at rest is on.

How pros do it

  • Run three or five members, never two or four, spread across failure domains so no rack or zone holds a majority; keep control-plane nodes dedicated to the control plane.
  • Give etcd its own SSD or NVMe volume (provisioned IOPS in the cloud) and alert on etcd_disk_wal_fsync_duration_seconds p99 above 10 ms and etcd_disk_backend_commit_duration_seconds p99 above 25 ms.
  • Keep compaction enabled, defragment members one at a time during quiet hours, and alert on DB size above roughly 70% of the backend quota and on the NOSPACE alarm.
  • Alert on etcd_server_has_leader, leader changes, failed proposals, and member health so a degraded cluster (one member down) pages before the second failure takes quorum.
  • Snapshot on a schedule that meets your RPO and before every upgrade; verify each snapshot, store it off-cluster and encrypted, and rehearse a timed restore into a scratch environment on a fixed cadence.
  • Enable encryption at rest for Secrets, restrict ports 2379 and 2380 to the control plane, and treat snapshots as credential material.
  • Write down who may run --force-new-cluster or a restore and under what conditions; the fast path in a quorum loss is almost always to wait for members to return.

Questions people ask

Can I run etcd with two members for a small cluster?

Say no and derive it: two members need both for quorum, so either failure stops the cluster; you get the cost of replication with the availability of a single node. Then give the rule: one member for throwaway clusters, three for anything that matters, five when you need to survive two failures. Deriving it from the majority rule is what they want, not the numbers.

If the leader dies, how long is the control plane down?

Say 'about one election timeout, a second or so with defaults', during which writes stall and the API server retries, so clients usually see a blip rather than an outage. Then redirect to the real problem: frequent leader changes, which point at disk or network, and the metric that shows them, etcd_server_leader_changes_seen_total.

kubectl is slow or timing out but the nodes are fine. How do I tell whether etcd is the cause?

Name the evidence on both sides: on the API server, etcd_request_duration_seconds; on etcd, wal_fsync p99, leader changes, and the logs for 'apply request took too long'. Then say the signature out loud: intermittent kubectl timeouts and NotReady flapping with idle CPU is disk latency. Reaching for the metrics before restarting anything is the point.

How often should I take snapshots?

Answer with the recovery point objective, not a number: match the cadence to your RPO, commonly every 15 to 30 minutes for self-managed production, plus one before every upgrade or risky change. Then add that a snapshot you have never restored is a hope, so you rehearse the restore on a schedule and time it against the RTO.

Do I need to care about etcd on a managed cluster?

Say you cannot operate it but you still hit its limits: object size, write rate, watch fan-out, and provider-side control-plane latency all surface in your cluster. Then say what changes for backups: you cannot snapshot it yourself, so workload-level backups through GitOps or a tool like Velero are your restore story.

Why is my etcd database 1.8 GiB when the cluster only has a few hundred pods?

Give the three candidates: history that has not been compacted, fragmentation left after compaction, or a churny writer such as Events or a controller updating status in a loop. Then say how you tell them apart: compare total size with in-use size, count keys by resource prefix, then compact and defragment. Naming the comparison is what separates knowing from guessing.

What does 'mvcc: required revision has been compacted' mean?

Say a client asked to read or watch from a revision older than the last compaction. Kubernetes surfaces it as 'too old resource version' and the client re-lists; it is normal in small doses. Connecting the etcd message to the API server symptom is the answer.

Further reading

Drills · 8

Answer in your head, or out loud, before you reveal. Mark each one: "Again" brings it back, "Got it" counts on your desk.

1 Pick the strongest answer

Your etcd cluster has 3 members. How many can you lose before writes stop, and why would adding one more member not help?

  1. It tolerates half the members failing; adding one raises tolerance by one. Half is not a majority. Tolerance grows only at odd counts: 3, 5, 7.
  2. A strict majority must remain: 3 members tolerate floor((3−1)/2) failures. One more member makes the count even, which raises the majority needed without raising the failures tolerated. Quorum is (n/2)+1. 3→2 needed (1 failure), 4→3 needed (still 1 failure), 5→3 needed (2 failures).
  3. Tolerance depends on the number of API servers, not etcd members. API servers are stateless clients of etcd; etcd's own membership decides quorum.
  4. It can lose all but one member; the survivor keeps serving from its local copy. A lone member cannot form a majority; it refuses writes to avoid split-brain.
In short

A majority must stay up: 3 members survive 1 loss and 5 survive 2, and an even count adds cost but no extra tolerance.

Why

Raft commits a write when a majority acknowledges it, so availability is a function of how many members can still form that majority. Even sizes buy nothing but cost: 4 members tolerate 1 failure just like 3, while needing more disk and network. Interviewers ask this to see whether you reason from the majority rule rather than from memorized numbers.

The common mistake

Saying an extra member always adds safety. Four members tolerate the same single failure as three, at more replication cost, and make a split more likely.

Read the docs

2 Answer out loud

How does etcd keep cluster state consistent across three members? What happens when one member dies, and when two do? Three to five sentences.

In short

A strong answer says a write commits when a majority acknowledges it, so one dead member is fine and two dead members stop writes.

What a strong answer does
  • mechanism: Leader serializes writes, a write commits after a majority acknowledges it (durably), followers replay the log; reads are linearizable through the leader by default.
  • failure reasoning: One dead: writes continue, possibly a re-election if it was the leader; two dead: no majority, cluster refuses writes (and stale reads), API server unavailable while workloads keep running.
  • communication: Mechanism, then the two failure cases, in three crisp sentences.
Why

Interviewers score whether you separate the data plane from the control plane in the two-failure case and whether "majority" is the word you reason from.

The common mistake

Saying two dead members means data loss or workloads going down. The surviving member still holds every committed write; what stops is the control plane, not the pods.

3 Pick the strongest answer

You are paged: control-plane logs are full of etcdserver: apply request took too long, the etcd leader keeps changing, and kubectl intermittently times out. CPU is idle everywhere. What do you suspect first?

  1. Too many API servers are connected, overloading the leader's CPU. CPU is idle; and API server count is rarely the bottleneck.
  2. Kubernetes objects are too large, so watches are slow. Large objects affect watch and read throughput, not leader stability.
  3. Slow disk fsync on the etcd data directory: Raft log persistence stalls, heartbeats miss, followers start elections, and the API server waits on etcd. etcd's wal_fsync_duration is the canonical metric; p99 above ~10 ms on the WAL disk produces exactly this pattern.
  4. The cluster has too many members, slowing consensus. Member count raises commit latency modestly, but it does not cause fsync 'took too long' warnings.
In short

Slow disk fsync on the etcd data directory causes the timeouts and the leader changes.

Why

Every Raft write is durable before it is acknowledged, so etcd's write path is bounded by disk fsync latency. Shared or network-backed disks with variable latency stall the leader long enough for followers to time out and elect a new leader; the API server, waiting on etcd, times out in turn. The fix is dedicated low-latency storage for etcd (and watching etcd_disk_wal_fsync_duration_seconds).

The common mistake

Reaching for more etcd members or bigger CPUs. Members add fault tolerance, not write capacity, and the metrics here say fsync; the fix is physical storage.

Read the docs

4 Scenario: what do you do next?

02:10. A three-member self-managed control plane. Two control-plane nodes were in the same rack; the rack lost power. kubectl get nodes hangs, then returns Unable to connect to the server: EOF. Workloads on worker nodes are still serving traffic. The on-call engineer wants to "restart etcd on the remaining node so it becomes leader".

Step 1. What is the state of the cluster, and what is your first move?

  1. Delete the etcd data directory on the survivor and re-join it. There is no cluster to re-join, and you would destroy the only intact copy of state.
  2. Drain the worker nodes to be safe. Drain needs the API server, which is down, and it would turn a control-plane outage into a customer outage.
  3. Restart etcd on the surviving member with --force-new-cluster so it can take writes. That discards the other two members' identities and risks divergence if the rack comes back; it is a last resort, not a first move.
  4. etcd has lost quorum (1 of 3), so the control plane is unavailable but workers keep running from their last known state; first confirm workloads are healthy and communicate that the data plane is up while control is down. Correct diagnosis and mitigation-first: the outage is a control-plane outage, not a customer outage yet. Say so before touching etcd.

Step 2. Facilities says power is back in 20 minutes. What now?

  1. Add two new members to the survivor to rebuild quorum. Membership changes need quorum; the survivor cannot commit them.
  2. Scale the workers down to reduce load on the control plane when it returns. No API server, so no scaling; and load on return is not the risk.
  3. Restore last night's snapshot onto the survivor now to get the API back faster. That rolls the cluster back hours and creates a split history when the other members return.
  4. Wait for the two members to return; quorum re-forms automatically and the API server recovers. Meanwhile verify the latest snapshot exists and is restorable, in case the members come back corrupted. The cheapest, safest recovery is the members coming back. Preparing the fallback in parallel is what a senior engineer does with the 20 minutes.

Step 3. Power returns; both members rejoin and the API server is back in three minutes. For the postmortem, what is the systemic fix?

  1. Spread control-plane members across failure domains (racks/zones), alert on etcd member count and leader changes, and rehearse snapshot restores on a schedule. Mechanisms: topology that keeps quorum through a rack loss, alerts that catch the degraded state early, and a practiced recovery.
  2. Document the --force-new-cluster procedure so it is faster next time. That optimizes the dangerous path instead of removing the need for it.
  3. Move to five members in the same rack for more redundancy. Five members in one failure domain still lose quorum when the rack does.
In short

etcd lost quorum, so the control plane is down but workloads keep running; wait for the members to return instead of forcing a new cluster.

Why

Losing quorum makes the control plane unavailable while the data plane keeps running, which is the single most important thing to say out loud in an interview. The tempting moves (force a new cluster, restore a snapshot) all trade a recoverable outage for a data-divergence risk. Topology and rehearsed restores are the fixes.

Read the docs

5 Design round

Design the backup and disaster-recovery story for a self-managed Kubernetes control plane serving 400 nodes. Cover etcd topology, backup cadence, restore procedure, and how you would know the plan works before you need it.

  • RPO of 15 minutes for cluster state; RTO of 30 minutes for the API server.
  • Two datacenters 30 ms apart; no third site.
In short

A strong answer places a majority of etcd members on purpose, snapshots often enough for the RPO, and rehearses the restore.

A strong answer covers
  • Three (or five) etcd members spread across failure domains; discusses that two sites cannot give a majority-safe split and how to place members.
  • Dedicated low-latency disks for etcd; fsync latency monitored.
  • Scheduled etcdctl snapshot save at a cadence that meets the RPO, shipped off-cluster, with integrity checks.
  • A written, rehearsed restore procedure (new cluster identity, API server pointing at restored members) and its consequences (state rollback, controllers reconciling).
  • Alerts on member count, leader changes, DB size, and backup age.
  • Regular game-day restores into a scratch environment to prove RTO.
What a strong answer does
  • design quality: Topology that reasons about majority across two sites, disk requirements, snapshot cadence matched to RPO, rehearsed restore matched to RTO, alerts.
  • tradeoffs: Two or more with decisions: where the majority lives, snapshot cadence vs load, restore rollback cost.
  • communication: Restates RPO/RTO, states the placement decision explicitly, walks the restore, ends with how it is proven.
Why

Staff-level answers name the two-site majority problem explicitly instead of hand-waving "multi-region etcd", match cadence to RPO, and treat restore as a rehearsed procedure with known side effects.

Read the docs

6 Quick recall

And with five members, how many can you lose and still take writes?

In short

A 5-member etcd cluster can lose 2 members and still accept writes.

Accepted

2 · two

Why

Quorum for 5 is 3, so 2 failures are tolerated; 3 members tolerate 1; 7 tolerate 3.

7 Read the output

Nobody can create anything. What is happening, and in what order do you recover?

$ etcdctl endpoint status -w table
+------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+---------------------------------------------+
|        ENDPOINT        |        ID        | VERSION | DB SIZE | IS LEADER | IS LEARNER | RAFT TERM | RAFT INDEX | RAFT APPLIED INDEX |                   ERRORS                    |
+------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+---------------------------------------------+
| https://10.0.0.11:2379 | 8e9e05c52164694d |  3.5.12 |  2.1 GB |      true |      false |        14 |    9812233 |            9812233 | memberID:10276657743932975437 alarm:NOSPACE |
+------------------------+------------------+---------+---------+-----------+------------+-----------+------------+--------------------+---------------------------------------------+

$ etcdctl alarm list
memberID:10276657743932975437 alarm:NOSPACE

$ kubectl create configmap t --from-literal=a=b
error: etcdserver: mvcc: database space exceeded
  1. Delete the largest Kubernetes objects to free space immediately. Deleting keys creates new revisions; space is only reclaimed by compaction and defragmentation.
  2. The backend hit its 2 GiB quota. Compact old revisions, defragment each member, then disarm the alarm; afterwards fix the source of churn and raise the quota only if the working set genuinely needs it. NOSPACE is raised when the DB exceeds the quota; writes are refused until the alarm is disarmed, and disarming before compacting and defragging just trips it again.
  3. The node's disk is full; add disk and restart etcd. This is etcd's own backend quota, independent of free disk space.
  4. Restart the API servers to clear their caches. The API server is not holding the space; etcd's MVCC history is.
In short

The database hit its 2 GiB quota; compact, then defragment each member, then disarm the NOSPACE alarm.

Why

etcd keeps every revision of every key until compaction removes history older than a revision; defragmentation then rewrites the backend file to return the space. When the file exceeds the quota, etcd raises NOSPACE and refuses writes cluster-wide, which is why kubectl create fails while reads still work. Kubernetes enables auto-compaction by default, so hitting NOSPACE usually means a controller is writing at a very high rate.

Read the docs

8 Find what's broken

This unit runs on each control-plane node of a cluster that is supposed to tolerate one node failure. Reviewers flagged two lines that will cause an outage within months. Which?

[Unit]
Description=etcd
After=network-online.target

[Service]
Type=notify
ExecStart=/usr/local/bin/etcd \
  --name cp-1 \
  --data-dir /var/lib/etcd \
  --initial-cluster cp-1=https://10.0.0.11:2380,cp-2=https://10.0.0.12:2380 \
  --initial-cluster-state new \
  --listen-client-urls https://0.0.0.0:2379 \
  --advertise-client-urls https://10.0.0.11:2379 \
  --auto-compaction-retention 0 \
  --quota-backend-bytes 8589934592
Restart=always
RestartSec=5s

[Install]
WantedBy=multi-user.target
In short

Two members give no fault tolerance, and turning off etcd's own compaction removes a safety net against NOSPACE.

What's broken
  • Line 10: A two-member cluster has no fault tolerance: losing either member loses quorum. The initial cluster needs three members.
  • Line 14: auto-compaction-retention 0 leaves etcd with no compaction of its own, so history is bounded only by the API server's --etcd-compaction-interval; if that is disabled or the API server is down, revision history grows until the backend quota trips NOSPACE and the cluster refuses writes.
Why

Two slow-burning misconfigurations. Membership decides tolerance, and two members tolerate nothing. Compaction is what keeps MVCC history bounded; disabling it converts normal controller churn into an eventual write outage, and a large quota only delays the day. Interviewers like this one because both lines look innocuous.

Read the docs

That's the last lesson in mission 09 Pick your next mission
Drill · etcd
0:00

Loading…