etcd: Distributed Key-Value Store with Raft
What you'll learn: How etcd uses Raft to provide strongly consistent configuration storage that powers Kubernetes and other distributed systems.
What is etcd?
etcd is a distributed key-value store designed specifically for storing configuration data and coordinating distributed systems. It implements the Raft consensus algorithm to ensure every read returns the most recently written value, even during network partitions and server failures.
Think of etcd as a highly reliable shared notebook that multiple servers can read from and write to simultaneously. Unlike eventually consistent systems, etcd guarantees that when you write a value, all subsequent reads will see that value—critical for storing cluster state, service discovery data, and configuration that systems like Kubernetes depend on.
How etcd Implements Raft
etcd organizes nodes into a Raft cluster where one node becomes the leader and others become followers. Every write request goes through the leader, which uses AppendEntries RPCs to replicate the operation to followers. Only after a majority confirms replication does etcd commit the entry and return success to the client.
The key-value pairs are stored in a replicated log. Each modification (put, delete) becomes a log entry with a unique index and term. etcd uses Raft's log matching property to ensure all nodes apply operations in the same order. If the leader fails, followers hold an election using RequestVote RPCs, and the new leader has all committed entries.
Why Kubernetes Uses etcd
Kubernetes stores all cluster state—pod definitions, services, secrets—in etcd. The strong consistency guarantee means when you create a pod, the scheduler immediately sees it. This reliability is why etcd sacrifices availability during partitions (favoring CP in CAP theorem) rather than serving stale data.
Key Takeaway: etcd implements Raft to provide linearizable reads and writes for critical configuration data, making it the foundation for systems like Kubernetes that require strongly consistent coordination.