Course contentsShow
← Docker, Kubernetes & CI/CD
Lesson 246 of 8024. Kubernetes Architecture and Core ObjectsFree lesson

Storing Cluster State in etcd

You will understand how the API server utilizes etcd as a consistent, distributed key-value store to maintain the source of truth.

In this lesson, you will learn how Kubernetes relies on etcd to serve as the brain of your cluster by acting as the single source of truth for all configuration and state data.

The Role of etcd

If the Kubernetes API Server is the front door of your cluster, etcd is the filing cabinet where everything is kept. etcd is a distributed, consistent key-value store. It is the only component in the entire Kubernetes architecture that actually saves data to disk.

When you submit a manifest to the API Server—whether you are creating a Pod, a Service, or updating a deployment—the API Server validates your request and then writes that information into etcd. Because etcd is designed for high availability and consistency, it ensures that every node in your control plane has a synchronized view of what the cluster should look like.

Visualizing the State

You can think of etcd as a hierarchical directory. If you were to look at the data structure inside etcd, you would see paths representing your objects, like this:

/registry/pods/default/my-web-app
/registry/services/specs/my-load-balancer
/registry/deployments/default/frontend-app

Whenever the Controller Manager or the Scheduler needs to make a decision, they don't look at the cluster nodes directly; they query the API Server, which retrieves the current state from etcd. If the Scheduler notices a new Pod entry in etcd that hasn't been assigned to a node yet, it updates the record in etcd to bind that Pod to a specific worker node.

The beauty of this design is that the other control plane components are "stateless." If a Controller Manager crashes, it can simply restart, read the current state from etcd via the API Server, and immediately resume its work without losing track of what happened before. By offloading the memory of the cluster to a dedicated, reliable tool like etcd, Kubernetes maintains a "Source of Truth" that is decoupled from the active processes running your containers.

Key Takeaway: The etcd store is the single, distributed source of truth for the entire cluster, allowing Kubernetes components to remain stateless while maintaining a consistent record of all object configurations.