etcd: The Cluster Database
What You'll Learn
You'll understand how etcd serves as Kubernetes' reliable memory, storing all cluster state information in a distributed key-value store.
The Cluster's Source of Truth
In the last lesson, you learned that the API Server is Kubernetes' gateway. But where does it actually store all that cluster information—which pods are running, what deployments exist, what configurations are active?
That's where etcd comes in. Think of etcd as the cluster's brain—a highly reliable database that stores every piece of cluster state as key-value pairs. When you create a pod, define a service, or update a deployment, that information ultimately gets written to etcd.
Why etcd Matters
etcd is a distributed key-value store, meaning it can run on multiple machines simultaneously for reliability. If one etcd instance fails, others maintain the data. This distributed nature uses the Raft consensus algorithm to ensure all copies stay synchronized—every etcd member agrees on what the current state is.
The API Server is the only component that directly reads from and writes to etcd. When you run a command or when a controller needs cluster information, it goes through the API Server, which then queries etcd. This centralized access pattern keeps data consistent and secure.
What Gets Stored
Everything about your cluster lives in etcd:
- All resource definitions (pods, services, deployments)
- Configuration data and secrets
- Network policies and storage configurations
- Cluster membership information
If etcd loses data, your cluster loses its memory. That's why backing up etcd is critical for disaster recovery.
Analogy
Imagine a restaurant where the API Server is the head waiter taking orders, but etcd is the central order system in the kitchen that remembers every table's order, dietary restrictions, and payment status. Without that system, the restaurant can't function.
Key Takeaway: etcd is Kubernetes' distributed key-value database that stores all cluster state, serving as the single source of truth accessed exclusively through the API Server.