Kubernetes
Why Kubernetes Needs etcd: The Database Behind the Control Plane (Part-I)
Most engineers know Kubernetes uses etcd. Fewer understand why it needs it. This article explores the state-management problem etcd solves and why the control plane depends on it.
If you've spent any time learning Kubernetes, you've probably encountered etcd fairly early. Most architecture diagrams place it right in the center of the control plane, often connected to almost every major component. The explanation that usually follows is fairly simple: etcd is a distributed key-value store used by Kubernetes to store cluster state.
While that explanation is technically correct, it often leaves engineers with a much more interesting question. Why does Kubernetes need a database in the first place?
After all, Kubernetes is not a traditional business application. It isn't processing payments, managing user accounts, or storing product catalogs. Its primary responsibility is orchestrating workloads across a cluster of machines. At first glance, a distributed database sitting at the heart of the control plane feels like an implementation detail rather than a fundamental architectural requirement.
The reality is quite different. Kubernetes does not use etcd simply because applications need databases. It uses etcd because the entire architecture of Kubernetes depends on maintaining a reliable and consistent representation of state. Once you start looking at Kubernetes through that lens, etcd stops feeling like a supporting component and starts looking like the foundation upon which the rest of the control plane is built.
In this article, we'll focus on the problem etcd solves rather than the implementation details behind it. We'll leave topics such as Raft, consensus, leader election, and quorum for later parts in this series. Before discussing how etcd works, it's more important to understand why Kubernetes cannot function without something like etcd in the first place.
Kubernetes Is a State Management System Disguised as a Container Orchestration Platform
One of the most common misconceptions about Kubernetes is that it is primarily a container management platform. This is understandable because containers are the most visible part of the system. Engineers create Deployments, observe Pods being scheduled, and monitor containers running across worker nodes. From the outside, Kubernetes appears to be a sophisticated system for launching and scaling containers.
However, containers are not actually the most important thing Kubernetes manages. State is.
To understand why, consider a simple Deployment that specifies three replicas of an application. Most engineers instinctively interpret that configuration as an instruction to create three Pods. While that interpretation isn't entirely wrong, it misses the deeper architectural model. The Deployment is not telling Kubernetes to perform a one-time action. It is describing what the cluster should continuously look like.
That distinction becomes important the moment something fails. Suppose one of the Pods crashes. Kubernetes immediately creates a replacement. Suppose the node hosting that Pod disappears entirely. Kubernetes schedules a replacement elsewhere. Suppose an operator accidentally deletes a Pod. Once again, Kubernetes recreates it.
In all of these situations, Kubernetes is not protecting a particular container. The original container may be gone forever. Instead, Kubernetes is protecting the desired state represented by the Deployment. The specific containers are disposable. The declared state is not.
This idea sits at the heart of the Kubernetes architecture. Every major control plane component exists to help the cluster converge toward a desired state. Controllers compare what currently exists against what should exist. The scheduler determines where workloads should run. Kubelets ensure workloads actually execute on worker nodes. Although these components have different responsibilities, they are all working toward the same objective: making reality match a declared specification.
Once you recognize that Kubernetes is fundamentally a state management system, an important question naturally follows. If the desired state is so important, where is it stored? More importantly, how does Kubernetes ensure that desired state survives failures, restarts, upgrades, and crashes that occur across a distributed environment?
The answer to that question leads directly to etcd.
The Problem With Storing Cluster State in Memory
At first glance, storing cluster state in memory sounds perfectly reasonable. Modern servers have large amounts of RAM, memory access is extremely fast, and many applications rely heavily on in-memory data structures. If Kubernetes only needed speed, keeping everything in memory would be an attractive option.
The problem is that Kubernetes operates in an environment where failures are expected rather than exceptional.
Imagine that the API Server stores all cluster information in memory. Deployments, Services, Secrets, ConfigMaps, Node registrations, and every other resource exist only within the memory space of a running process. As long as that process remains alive, everything appears normal. Controllers can retrieve state, schedulers can make decisions, and users can interact with the cluster.
Now consider what happens when that process restarts.
The moment memory is lost, the control plane loses its understanding of the cluster. Deployments disappear. Service definitions disappear. Configuration data disappears. Even if workloads continue running temporarily on worker nodes, the control plane no longer has an authoritative record of what should exist.
The consequences become even more severe when we move beyond individual process failures. Machines crash. Virtual machines are replaced. Operating systems reboot. Cloud instances fail unexpectedly. If Kubernetes relied solely on local memory, every infrastructure failure would risk erasing part of the cluster's state.
This is why persistent storage is not an optional feature for Kubernetes. It is a requirement. The desired state of the cluster must survive individual process failures, machine failures, and control plane restarts. Otherwise, the entire reconciliation model breaks down because there is no longer a reliable reference point against which reality can be compared.
However, persistence alone does not solve the entire problem. Storing state on disk is relatively easy. Maintaining a consistent view of that state across multiple distributed components is where things become significantly more challenging.
And that is the real problem Kubernetes is trying to solve.
The Distributed Systems Problem Kubernetes Actually Has
At this point, it is tempting to think that Kubernetes simply needed a database because it required persistent storage. While persistence is certainly important, it is only one piece of the puzzle. If persistence were the only requirement, Kubernetes could have chosen from countless storage solutions. The more interesting challenge emerges once we remember that Kubernetes is not a single process running on a single machine. It is a distributed system composed of many independent components that must cooperate to manage the cluster.
Consider a typical Kubernetes control plane. There is an API Server accepting requests from users and internal components. There are controllers continuously monitoring resources and reconciling state. There is a scheduler making placement decisions for new workloads. There are kubelets running on worker nodes, constantly reporting status information and executing instructions. Each of these components has its own responsibilities, its own lifecycle, and its own view of the cluster.
The difficulty arises because all of these components are making decisions based on cluster state. The scheduler decides where a Pod should run based on information about nodes, resources, taints, tolerations, and existing workloads. Controllers decide whether additional resources need to be created or removed. Autoscalers determine whether applications should scale up or down. None of these decisions happen in isolation. They all depend on a shared understanding of the current state of the system.
Now imagine what would happen if that understanding became inconsistent. Suppose one component believes a Deployment should have three replicas while another believes it should have five. Suppose one controller sees a recently updated configuration while another is operating on stale information. Suppose the scheduler places workloads based on node information that is no longer accurate. The result is not simply a minor inconvenience. The result is conflicting decisions being made throughout the control plane.
This is one of the defining challenges of distributed systems. The moment multiple machines participate in decision making, agreement becomes difficult. Network delays introduce uncertainty. Processes restart unexpectedly. Machines fail. Messages arrive out of order. Different components may temporarily observe different versions of reality. Building reliable distributed systems is largely about managing these situations without allowing the system to drift into an inconsistent state.
What makes Kubernetes particularly interesting is that its entire operating model depends on agreement. The reconciliation loops that power the platform only work if every component is working from the same source of truth. A controller cannot reliably reconcile resources if it is observing different state than the scheduler. The scheduler cannot make correct placement decisions if it is working from stale information. Before Kubernetes can orchestrate containers, scale applications, or recover from failures, it must first solve the problem of maintaining a consistent representation of cluster state across the entire control plane.
That requirement is what transforms etcd from a simple storage system into one of the most critical components in the Kubernetes architecture.
Why the Control Plane Needs a Single Source of Truth
When engineers discuss Kubernetes, they often describe the various control plane components independently. We talk about the scheduler, the controller manager, the API Server, and the kubelet as separate pieces of the system. While that separation is useful for understanding responsibilities, it can sometimes hide an important architectural reality. These components are not independent decision makers. They are participants in a larger system that must operate according to a shared understanding of state.
Imagine for a moment that each component maintained its own local database containing cluster information. The scheduler stores information about nodes and workloads. Controllers maintain their own copies of Deployment specifications. The API Server keeps another version of the same data. Initially, everything might appear to work. However, the moment updates begin flowing through the system, inconsistencies would start to emerge. Different components would observe different versions of the same resource. Synchronization would become increasingly difficult. Debugging cluster behavior would quickly turn into a nightmare.
This is precisely why Kubernetes is designed around a single authoritative source of truth. Instead of allowing every component to own state, the control plane centralizes cluster state in one location. Whenever a Deployment is created, updated, or deleted, that change is reflected in the authoritative store. Whenever a controller needs to understand the current state of a resource, it consults that same source. Whenever the scheduler makes a decision, it does so based on information derived from that shared state.
The importance of this approach becomes even more apparent during failures. Suppose a controller crashes and restarts. It does not need to reconstruct state from scattered local databases or attempt to synchronize with every other component. It simply reconnects, reads the current state from the authoritative source, and resumes operation. Similarly, if a scheduler is replaced or upgraded, it can immediately rebuild its understanding of the cluster because the source of truth remains intact.
Another advantage of this model is that it simplifies reasoning about the system. Distributed systems are already difficult enough without introducing multiple competing versions of state. By establishing a single authoritative record of cluster information, Kubernetes provides a foundation upon which all other components can operate. The control plane may be composed of many moving parts, but they are ultimately coordinating around the same shared representation of reality.
This design principle appears repeatedly throughout Kubernetes. Controllers do not directly communicate desired state to one another. Instead, they observe changes from the shared state store. Schedulers do not receive instructions from Deployments. They react to resources that have already been persisted. The API Server does not attempt to maintain private ownership of cluster data. Its role is to act as the gateway through which state is validated, stored, and retrieved.
Once you understand this architectural principle, etcd begins to look less like a database and more like the foundation that enables every other control plane component to function coherently.
How etcd Becomes the Foundation of Reconciliation
Earlier, we discussed reconciliation as one of the defining concepts in Kubernetes. Controllers continuously compare the actual state of the cluster with the desired state declared by users. Whenever those two states diverge, controllers take corrective action to bring them back into alignment. It is an elegant model because it allows Kubernetes to recover from failures automatically rather than relying on operators to intervene manually.
However, reconciliation only works if there is a reliable definition of desired state.
Imagine a Deployment that specifies three replicas. The Deployment controller needs to know that the desired replica count is three before it can determine whether corrective action is required. If only two Pods are running, it must create another one. If four Pods are running, it must remove one. Every decision the controller makes is derived from the desired state stored somewhere within the system.
This is where etcd becomes indispensable. The desired state of the cluster ultimately resides within etcd. Controllers do not invent desired state. They do not maintain independent copies of it. Instead, they observe resources whose authoritative definitions have already been persisted. When a controller reconciles a Deployment, it is effectively comparing the real world against information that originates from etcd.
The same pattern extends throughout the entire platform. The ReplicaSet controller reconciles replica counts. The Job controller reconciles completed tasks. The StatefulSet controller reconciles ordered workloads. Even custom controllers built by platform teams follow the same model. They watch resources, observe state changes, and continuously attempt to move reality toward the desired state stored within the cluster.
This is one of the reasons Kubernetes scales conceptually so well. Every controller follows the same basic pattern. Observe state. Compare desired and actual conditions. Take action if necessary. Repeat indefinitely. The complexity of the system comes not from individual reconciliation loops but from the fact that hundreds of these loops may be operating simultaneously across the cluster.
What keeps this model from descending into chaos is the fact that every controller is ultimately working from the same source of truth. The Deployment controller, the scheduler, the kubelet, and every other participant in the control plane are observing state derived from the same authoritative record. They may have different responsibilities, but they are all responding to the same version of reality.
This is why etcd sits at the center of the Kubernetes architecture. It is not simply a persistence layer. It is the foundation that makes reconciliation possible. Without a durable and consistent source of truth, controllers would have nothing reliable to reconcile against. The declarative model that makes Kubernetes so powerful would effectively collapse because every component would be forced to operate on uncertain or potentially conflicting information.
In many ways, the rest of the Kubernetes control plane can be viewed as a collection of reconciliation engines. etcd is the system that gives those engines something meaningful to reconcile.
Following a Deployment: From kubectl apply to etcd
Up to this point, we've discussed etcd as the source of truth for Kubernetes, but the discussion has been somewhat abstract. To understand its importance more concretely, it helps to follow the lifecycle of a Deployment and observe where etcd fits into the picture.
Consider a developer running the following command:
kubectl apply -f deployment.yaml
At first glance, it is easy to imagine this request flowing directly toward the scheduler, eventually resulting in Pods being created on worker nodes. After all, the visible outcome is the creation of running containers. However, Kubernetes deliberately avoids operating in that manner.
The first destination for the request is the Kubernetes API Server. The API Server acts as the front door of the control plane. Every meaningful interaction with the cluster passes through it, whether that interaction originates from a human operator, an automation pipeline, a controller, or another internal component. Before Kubernetes even considers creating a Pod, the API Server begins processing the request.
The request first passes through authentication and authorization checks. Kubernetes must verify who is making the request and whether they have permission to perform the requested action. Once those checks succeed, the object is validated against the Kubernetes API schema. Admission controllers may then inspect, mutate, or reject the request based on organizational policies. Only after the request successfully navigates this sequence of checks does Kubernetes consider it a valid change to cluster state.
At this point, something important happens.
The Deployment is written into etcd.
Not scheduled.
Not executed.
Not converted into Pods.
Stored.
This ordering is one of the most important design decisions in Kubernetes. Before any controller reacts to the Deployment, before the scheduler evaluates node placement, and before a kubelet launches a container, the desired state must first be persisted inside the authoritative state store.
This may seem like a small implementation detail, but it fundamentally shapes how the control plane behaves. Kubernetes does not create state and then record it afterward. Kubernetes records state first and then allows the rest of the system to react to it.
Once the Deployment exists inside etcd, controllers observing the API become aware of the new object. The Deployment controller notices that a Deployment requiring three replicas now exists. It creates a ReplicaSet. The ReplicaSet controller observes that additional Pods are needed and creates Pod objects. The scheduler eventually notices unscheduled Pods and assigns them to nodes. Kubelets running on worker nodes observe those assignments and finally start containers.
By the time the first container begins executing, multiple control-plane components have already reacted to information that originated from etcd. In many ways, etcd is the first component in Kubernetes that truly learns about a new Deployment. Everything else is responding to a state change that has already been committed to the cluster's source of truth.
This perspective is useful because it changes how we think about Kubernetes. The scheduler is not receiving commands from users. Controllers are not processing YAML files directly. Instead, every major component is reacting to state transitions that have been recorded within the cluster. Kubernetes is fundamentally a system of observers and reconcilers operating around a shared representation of reality.
What Actually Lives Inside etcd?
One of the reasons etcd is sometimes misunderstood is that engineers often assume it stores only a small subset of Kubernetes data. In reality, the scope of information stored inside etcd is much broader than most people initially realize.
At a high level, etcd contains the authoritative representation of nearly every Kubernetes object that defines the state of the cluster. Deployments, ReplicaSets, Pods, Services, ConfigMaps, Secrets, PersistentVolumeClaims, StatefulSets, DaemonSets, Jobs, CronJobs, Namespaces, RBAC policies, and Custom Resource Definitions all eventually become entries within etcd.
This means that when an engineer creates a Deployment, the YAML file itself is not what Kubernetes remembers. What Kubernetes remembers is the internal representation of that resource stored within etcd. The same principle applies to Services, Secrets, and every other object managed by the platform. Once accepted by the API Server, these resources become part of the cluster's persistent state.
Node information also lives inside etcd. When worker nodes join the cluster, they register themselves through the API Server. Details about node capacity, labels, taints, conditions, and status updates eventually become part of the state stored within the control plane. This information is critical because schedulers and controllers depend on it when making decisions about workload placement and cluster health.
Another category of data stored inside etcd is operational state generated by Kubernetes itself. As controllers reconcile resources and workloads move through their lifecycle, Kubernetes continuously updates objects to reflect current conditions. Pod status changes, ReplicaSet ownership relationships, Deployment rollout progress, and countless other pieces of metadata are all represented as updates to objects stored within etcd.
Understanding this breadth is important because it highlights why etcd is often described as the memory of the cluster. It is not merely storing configuration. It is storing the information required for Kubernetes to understand both its desired state and its current state. Controllers use that information to make decisions. Schedulers use it to place workloads. Operators use it to observe the health and behavior of the system.
This is also why backup and disaster recovery procedures for etcd are treated so seriously in production environments. Losing etcd does not simply mean losing configuration files. It means losing the cluster's accumulated knowledge about itself. Every resource definition, every relationship between objects, and every piece of metadata that allows Kubernetes to reason about the world exists because it has been persisted within etcd.
When viewed from this perspective, etcd starts looking less like a database attached to Kubernetes and more like the system's long-term memory.
What Happens When etcd Goes Down?
Perhaps the clearest way to appreciate the importance of etcd is to imagine a cluster operating without it.
The first thing many engineers expect is that all running applications would immediately stop working. Surprisingly, that is usually not what happens. Existing Pods may continue running. Containers that are already executing on worker nodes often continue serving traffic. Applications may remain accessible for some time, and from the perspective of end users, everything might initially appear healthy.
This behavior can be misleading.
The reason workloads continue running is that worker nodes already know what they are supposed to be running. Kubelets maintain information about the Pods assigned to them, and containers do not instantly disappear simply because the control plane encounters a problem. As a result, the cluster can appear healthy even while one of its most important components is unavailable.
The problems begin to emerge the moment the control plane needs to make a decision.
Suppose an operator attempts to create a new Deployment. The request fails because the API Server cannot persist the object. Suppose a team wants to scale an application from three replicas to six. The update cannot be committed. Suppose a Pod crashes and requires replacement. Controllers may no longer be able to reconcile the desired state because the authoritative store is unavailable.
As the outage continues, the cluster gradually loses its ability to adapt. Existing workloads may continue running, but Kubernetes can no longer reliably manage them. New state changes cannot be committed. Controllers lose access to the information they depend upon. Scheduling decisions become impossible. Administrative operations fail. The cluster remains alive, but its control plane becomes increasingly ineffective.
This distinction is important because it reveals the true role of etcd. Kubernetes is often viewed as a system that runs workloads, but the control plane's primary responsibility is maintaining and evolving cluster state over time. Without access to that state, Kubernetes loses its ability to coordinate the system.
In many ways, an etcd outage resembles a severe form of memory loss. The cluster may still be executing previously known instructions, but it can no longer reliably learn, adapt, or make new decisions. The mechanisms that allow Kubernetes to reconcile state, recover from failures, and respond to changes all depend on the availability of the authoritative store.
This is why experienced platform engineers often describe etcd as the most critical component in the control plane. Losing a scheduler is recoverable. Losing a controller manager is recoverable. Losing an API Server instance is recoverable. Losing access to cluster state is an entirely different category of failure because every other component ultimately depends on that state to operate correctly.
Wrapping Up Part 1
At first glance, etcd appears to be a supporting component within the Kubernetes architecture. It sits quietly in diagrams, rarely receives the same attention as Pods or Deployments, and most engineers can work with Kubernetes for quite some time without interacting with it directly.
Yet as we've seen throughout this article, the control plane is built around the assumption that a durable, consistent, and authoritative representation of cluster state exists somewhere. Controllers depend on it. Schedulers depend on it. Reconciliation depends on it. Even the declarative model that defines Kubernetes depends on it.
The most useful way to think about etcd is not as a database attached to Kubernetes but as the foundation that allows the control plane to function. Kubernetes can only maintain desired state because that desired state is stored somewhere reliable. It can only recover from failures because it remembers what the cluster is supposed to look like. It can only coordinate independent components because those components share a common source of truth.
That source of truth is etcd.
In the next part of this series, we'll move deeper into the distributed systems challenges that etcd solves. We'll explore why storing data across multiple machines is far more complicated than it appears, how consensus algorithms emerged to address that problem, and why Kubernetes relies on the Raft protocol to ensure every control-plane component operates from the same version of reality.