Interview's MateKubernetes
Interview's Mate

Kubernetes

K8s · Workloads · GitOps · Cloud

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Kubernetes topics
Lesson 142/ 160
08. Cluster Administration & Managed Cloud Kubernetes

etcd Cluster Architecture, Raft Consensus, Backup & Restore

Operate etcd with Raft awareness and proven backup/restore procedures.

Advancedetcd · Raft · Backup/Restore3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

etcd Raft is a committee that writes only after a majority agrees; the snapshot is a sealed copy of the ledger at a chosen revision. The simple Kubernetes rule is: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.

Think of it like…

etcd Raft is a committee that writes only after a majority agrees; the snapshot is a sealed copy of the ledger at a chosen revision.

Where you’ve seen it

During a controlled maintenance window, the platform operator runs ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table. Expected evidence: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure. If the run instead shows this symptom, stop and restore the last known state: Stopping too many members loses quorum, a snapshot without the encryption and certificate plan may restore unusable Secrets, and rejoining a stale data directory can corrupt membership.

Words you’ll hear

etcd
For this lesson, etcd is the controlling idea: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.
Raft
Raft is the checkpoint; run ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table and inspect the owner chain. Stopping too many members loses quorum, a snapshot without the encryption and certificate plan may restore unusable Secrets, and rejoining a stale data directory can corrupt membership.
Backup/Restore
Backup/Restore is the outcome to preserve; the cost is explicit: An odd replicated etcd quorum survives member loss, but larger membership adds write latency and restore exercises are required before a backup is credible.
Verification evidence
The evidence command is ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table. It connects the declaration to this behavior: Operate etcd with Raft awareness and proven backup/restore procedures.

Visual diagram

Loading interactive diagram

Theory & deep dive

How etcd reaches the intended state

Operate etcd with Raft awareness and proven backup/restore procedures. Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.

The concrete checkpoint is ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table; compare the etcd owner, Raft state, and Backup/Restore outcome instead of treating YAML acceptance as proof.

Verify Raft, not only object creation

Run ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table after the change and correlate the result with Events and the owning object. Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.

Key takeaway: etcd is implemented only when this invariant remains observable: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.

Raft: failure boundary and production cost

Stopping too many members loses quorum, a snapshot without the encryption and certificate plan may restore unusable Secrets, and rejoining a stale data directory can corrupt membership. The prerequisite contract is concrete: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.

An odd replicated etcd quorum survives member loss, but larger membership adds write latency and restore exercises are required before a backup is credible. A safe design limits blast radius, records the last good configuration, and uses ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table as a deterministic rollback checkpoint.

Recover from Raft drift

Capture the current state with ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table, then correct the controlling manifest rather than patching a child object; the relevant divergence signal is specific: Stopping too many members loses quorum, a snapshot without the encryption and certificate plan may restore unusable Secrets, and rejoining a stale data directory can corrupt membership.

Key takeaway: Accept the trade-off consciously: An odd replicated etcd quorum survives member loss, but larger membership adds write latency and restore exercises are required before a backup is credible.

How it works, step by step

Step 1 of 4
Platform planner

1. Plan the lifecycle boundary

Inventory versions, capacity, state, backups, and ownership in a reversible plan: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.

etcd contract → owned state
Key numbers at this step
Goal
Operate etcd with Raft awareness and proven backup/restore procedures.
Owner
etcd

When to use it & trade-offs

What it is

Operate etcd with Raft awareness and proven backup/restore procedures. Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.

Why it matters: Stopping too many members loses quorum, a snapshot without the encryption and certificate plan may restore unusable Secrets, and rejoining a stale data directory can corrupt membership. The invariant at risk is specific: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure. The quickest fact check before changing the design is ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table.

When to reach for it

  • Use etcd to enforce this invariant: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.
  • Use Raft evidence from ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table in reviews and incident timelines. Operate etcd with Raft awareness and proven backup/restore procedures.
  • Choose the managed cloud or platform service route only when this cost is justified by governance or scale: An odd replicated etcd quorum survives member loss, but larger membership adds write latency and restore exercises are required before a backup is credible.

When to avoid or be careful

  • Avoid assuming etcd is complete after YAML submission; the required behavior is concrete: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.
  • Avoid treating the next symptom as random; check the owner and state with ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table first: Stopping too many members loses quorum, a snapshot without the encryption and certificate plan may restore unusable Secrets, and rejoining a stale data directory can corrupt membership.
  • Avoid adopting a heavier platform wrapper before measuring its cost: An odd replicated etcd quorum survives member loss, but larger membership adds write latency and restore exercises are required before a backup is credible.

Native, manual, and managed paths for etcd

Repeatable infrastructure control
Best for: Operate etcd with Raft awareness and proven backup/restore procedures. A concrete incident check is ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table.

Strengths: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.

Watch out: An odd replicated etcd quorum survives member loss, but larger membership adds write latency and restore exercises are required before a backup is credible. Recovery must also recognize this signal: Stopping too many members loses quorum, a snapshot without the encryption and certificate plan may restore unusable Secrets, and rejoining a stale data directory can corrupt membership.

Manual cluster mutation
Best for: Quickly testing the Raft assumption with ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table; the expected invariant is: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.

Strengths: ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table gives immediate feedback without first building a platform layer.

Watch out: A manual change can hide drift, and unlike etcd, it does not make this symptom self-documenting: Stopping too many members loses quorum, a snapshot without the encryption and certificate plan may restore unusable Secrets, and rejoining a stale data directory can corrupt membership.

Managed cloud or platform service
Best for: Teams that need Backup/Restore integrated with guardrails; the evidence path is ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table.

Strengths: Platform controls can wrap this exact behavior in policy or dashboards: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.

Watch out: The added platform ownership buys value at this cost: An odd replicated etcd quorum survives member loss, but larger membership adds write latency and restore exercises are required before a backup is credible.

Interview signals & numbers to know

When this topic comes up

  • Interview anchor: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.
  • Trace etcd to Backup/Restore through Raft; the invariant is: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.
  • Recognize the symptom: Stopping too many members loses quorum, a snapshot without the encryption and certificate plan may restore unusable Secrets, and rejoining a stale data directory can corrupt membership.
  • Justify the cost: An odd replicated etcd quorum survives member loss, but larger membership adds write latency and restore exercises are required before a backup is credible.
  • Verify with ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table instead of only inspecting YAML.

Benchmarks & rules of thumb

3 -
members tolerate one failure in a common quorum
5 -
members tolerate two failures but add operational and network cost
1 -
majority approval is required for committed writes

Common mistakes & follow-ups

Common interview mistakes

  • Debugging only the child object misses the etcd owner contract: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure.
  • Ignoring this telltale condition leads to unrelated changes: Stopping too many members loses quorum, a snapshot without the encryption and certificate plan may restore unusable Secrets, and rejoining a stale data directory can corrupt membership.
  • Repeating ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table without an owner for remediation wastes retry cost. An odd replicated etcd quorum survives member loss, but larger membership adds write latency and restore exercises are required before a backup is credible.

Likely interviewer follow-ups

  • How would API output and runtime evidence prove this behavior: etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure?
  • Which owner object, logs, and Events would you inspect for this symptom-Stopping too many members loses quorum, a snapshot without the encryption and certificate plan may restore unusable Secrets, and rejoining a stale data directory can corrupt membership-?
  • At what threshold would this cost become unacceptable: An odd replicated etcd quorum survives member loss, but larger membership adds write latency and restore exercises are required before a backup is credible?
Interview tip: Interview sequence: state the invariant, run ETCDCTL_API=3 etcdctl snapshot save etcd.snapshot; ETCDCTL_API=3 etcdctl snapshot status etcd.snapshot -w table, name the failure, then justify the cost. Invariant: Etcd replicates an append-only state machine with Raft, accepts linearizable writes through a leader, and recovers from an API-server-trusted snapshot plus the exact member or cluster restore procedure. Failure: Stopping too many members loses quorum, a snapshot without the encryption and certificate plan may restore unusable Secrets, and rejoining a stale data directory can corrupt membership. Cost: An odd replicated etcd quorum survives member loss, but larger membership adds write latency and restore exercises are required before a backup is credible.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply etcd Cluster Architecture, Raft Consensus, Backup & Restore with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Bootstrapping a Cluster from Scratch with kubeadm
Next topic
Zero-Downtime Kubernetes Cluster Upgrades (Control Plane & Worker Nodes)