What Is etcd in Kubernetes?

What Is etcd in Kubernetes?

A beginner-friendly tour of the small, quiet database that acts as the memory of every Kubernetes cluster: what it stores, how it stays correct, and why losing it is such a big deal.

Picture a huge library with many librarians. Every day, books are borrowed, returned, moved and reserved. If each librarian kept notes in a private notebook, chaos would follow within an hour: one would say a book is on shelf five, another would swear it was borrowed yesterday. The library needs one trusted record book that every librarian agrees on, and that survives even if a few librarians go home sick. In Kubernetes, that trusted record book is called etcd.

1The Problem: Where Does a Cluster Remember Things?

Before meeting etcd, understand what would go wrong without it.

A cluster is full of facts

A Kubernetes cluster is a group of machines that work together to run your applications. To do that job, the cluster must know many facts at every moment. Which applications should be running? How many copies of each? Which machine is each copy on? What secret passwords do the applications need? Which people are allowed to change what?

If these facts lived only in the memory of one program, a single restart would make the cluster forget everything. It would be like a shop owner who wakes up each morning with no idea what stock exists or what customers ordered.

Many components need the same truth

Kubernetes is made of several cooperating parts: a scheduler that picks machines, controllers that fix differences, and agents on every machine. They all need to read and update the same facts. If each kept its own copy, the copies would drift apart and the parts would work against each other.

Simple Analogy

Think of a group project where everyone edits their own private copy of a document. By the end, nobody knows which version is right. A single shared document that everybody reads and writes fixes the confusion. etcd is that shared document for the cluster.

flowchart LR
  A["Scheduler"] --> S["One shared source of truth"]
  B["Controllers"] --> S
  C["Node agents"] --> S
  D["Users and tools"] --> S
        
FIG 1 — Everyone needs the same record book

2So, What Exactly Is etcd?

etcd is a distributed, consistent key-value database that Kubernetes uses to store all of its cluster data.

Let us unpack that sentence one word at a time.

Word 1

Database

A place that stores information safely on disk so it is not lost when a program restarts.

Word 2

Key-value

Each piece of information has a name (the key) and content (the value), like a contact list where the name leads to the phone number.

Word 3

Distributed

The data is kept on several machines at once, so one machine failing does not lose anything.

Word 4

Consistent

All copies agree. When you read, you get the latest agreed value, not a stale or conflicting one.

Where the name comes from

The name is a playful mix of the Linux folder called “etc,” where configuration files live, and the letter “d” for distributed. The idea is a distributed place for configuration. It was created by the team at a company called CoreOS and is now a project hosted by the Cloud Native Computing Foundation, the same neutral home that hosts Kubernetes. It is written in the Go language, like Kubernetes itself.

2379
Default port for client requests
2380
Default port for members talking to each other
3
Smallest member count that survives a failure
i
Good to Know

etcd is a general-purpose tool that existed independently of Kubernetes. Kubernetes chose it because it is small, reliable and very good at keeping several machines in agreement.

3Vocabulary You Will Meet Again and Again

A short glossary makes everything after this chapter easier.

Term 1

Member

One etcd server. Several members together form an etcd cluster.

Term 2

Leader

The single member that accepts writes and tells the others what to record.

Term 3

Follower

A member that copies the leader’s decisions and is ready to take over.

Term 4

Raft

The agreement method etcd uses so members always settle on the same story.

Term 5

Quorum

A majority of members. Decisions only count when a quorum agrees.

Term 6

Revision

A counter that goes up with every change, giving each change a place in history.

Term 7

Watch

A way to say “tell me the moment this changes” instead of asking again and again.

Term 8

Snapshot

A saved copy of the whole database at one moment, used for backup and recovery.

4What Does Kubernetes Store in etcd?

Almost everything that describes the cluster itself.

Whenever you create something in Kubernetes, its description ends up in etcd. Here is what lives there.

Workload descriptions

The desired state of your Deployments, pods, jobs and other workloads: which images, how many copies, what limits. This is your wish list for the cluster.

Current status

Facts about what is actually happening, such as which node a pod was assigned to and whether it is ready.

Configuration and secrets

Settings stored in ConfigMaps and sensitive values stored in Secrets, including passwords and tokens.

Networking objects

Services, Ingress rules and network policies that describe how traffic should flow.

Access rules and identities

Roles, role bindings and service accounts that decide who may do what.

Cluster bookkeeping

Namespaces, node registrations, leases used for leader election among components, and custom resources added by extensions.

What is not stored there

etcd does not hold your application’s own data such as customer orders or photos, and it does not store container images or application logs. Those belong in databases, image registries and logging systems. etcd holds the map of the cluster, not the cargo it carries.

Simple Analogy

Think of a shipping port. The control office keeps records of which ship is at which dock, what each is meant to carry and who may enter. The goods inside the containers are not written in that register. etcd is the register.

!
Common Misconception

Many beginners think etcd stores application data. It does not. Putting large or fast-changing application data into the cluster’s own database is a fast way to hurt the whole cluster.

5How Kubernetes Talks to etcd

One door, one doorman.

Here is a surprising design choice: in a normal Kubernetes cluster, only one component talks to etcd directly. That component is the API server. The scheduler, the controllers, the node agents and even human administrators all speak to the API server, and the API server speaks to etcd.

Why a single gateway?

1

Safety

The API server checks who is asking and whether they are allowed. If everyone reached the database directly, these checks would be easy to skip.

2

Validation

The API server makes sure each object is well-formed before it is saved, so the database is not filled with nonsense.

3

Simplicity for others

Other components only need to learn one interface. They do not need to know how the database works internally.

4

Protection of the database

The API server can also cache reads and control the load, shielding etcd from being overwhelmed by hundreds of eager components.

graph TD
  U["Users and kubectl"] --> API["API Server"]
  SCH["Scheduler"] --> API
  CM["Controller Manager"] --> API
  KL["Kubelets on nodes"] --> API
  API --> E["etcd"]
        
FIG 2 — The API server is the only regular client of etcd
Simple Analogy

A bank vault has one guard at the door. Customers ask the guard, who checks identity, fetches the item and records the visit. Nobody walks into the vault directly, which keeps the contents safe and the records tidy.

6Staying in Agreement: The Raft Idea

How several machines can hold the same data without arguing.

A single database machine is a single point of failure. If it burns out, all the cluster’s memory disappears. So etcd runs on several machines that keep copies of the same data. The hard part is keeping those copies identical, even when messages are delayed or a machine suddenly stops. etcd solves this with a method called Raft, designed to be understandable and reliable.

The three roles

At any time each member plays one of three roles: follower, candidate or leader. Almost everyone is a follower most of the time. One member is the leader, who takes charge of all changes. A candidate is a member who is trying to become the new leader.

How a leader is chosen

The leader sends a tiny “I am still here” message to the followers again and again. If a follower stops hearing it for a random short time, it assumes the leader is gone, becomes a candidate and asks the others for votes. If a majority votes for it, it becomes the new leader. The random waiting time makes it unlikely that two members start an election at the same moment.

stateDiagram-v2
  [*] --> Follower
  Follower --> Candidate: No heartbeat heard
  Candidate --> Leader: Wins majority vote
  Candidate --> Follower: Another leader found
  Leader --> Follower: Sees a newer leader
        
FIG 3 — The three roles in Raft
Simple Analogy

Imagine a classroom with a class monitor. As long as the monitor keeps the class running, everyone stays calm. If the monitor vanishes and the room goes quiet, someone stands up and says “I can take over, who agrees?” Once most of the class raises their hands, a new monitor is chosen and the lesson continues.

How a change is recorded

Every change goes through the leader. The leader adds it to its log, sends it to the followers, and waits until a majority confirm they have stored it. Only then is the change considered committed and the client told it succeeded. Because a majority must always agree, two conflicting histories can never both be committed.

7Quorum and Choosing the Number of Members

Majority rules, and that shapes how many members you should run.

A quorum is a majority: more than half of all members. If you have three members, a quorum is two. With five, it is three. As long as a quorum is alive and can talk to each other, etcd keeps working. If the number of healthy members falls below a quorum, etcd stops accepting changes to protect correctness. It prefers to pause rather than risk giving wrong answers.

MembersQuorum neededFailures toleratedComment
110Fine for learning, risky for anything real
220Worse than one, because either failure stops the cluster
321Common starting point for production
431No better than three, with more cost
532Stronger protection for critical clusters
743Rarely needed, slower writes

Why odd numbers?

Look at the table: four members tolerate the same single failure as three, yet cost more and need more messages for every write. Odd numbers give the best protection for the price. Also, if a network split divides members into groups, an odd total guarantees that at most one group can hold a majority.

i
Why Not Just Add More?

More members do not mean more speed. Every write must be confirmed by a majority, so larger groups make writes slower. Three or five members are almost always enough.

8Following One Change from Request to Storage

What actually happens when you create something in Kubernetes?

1

You send a request

You ask Kubernetes to create an object, such as a Deployment. The request reaches the API server.

2

The API server checks it

It confirms who you are, whether you are allowed, and whether the object is valid.

3

The write reaches the etcd leader

The API server sends the new object to etcd. If it contacts a follower, the follower forwards it to the leader.

4

The leader replicates

The leader writes the change to its own log and sends it to followers.

5

A majority confirms

Once most members have safely saved the change to disk, it is committed.

6

You get your answer

The API server reports success, and watchers across the cluster are notified so they can act on the new object.

sequenceDiagram
  participant C as Client
  participant A as API Server
  participant L as etcd Leader
  participant F1 as Follower 1
  participant F2 as Follower 2
  C->>A: Create object
  A->>L: Write request
  L->>F1: Replicate entry
  L->>F2: Replicate entry
  F1-->>L: Saved
  F2-->>L: Saved
  L-->>A: Committed
  A-->>C: Success
        
FIG 4 — Lifecycle of a write
i
Why Disk Speed Matters

Members must flush each change to disk before confirming it. That means the speed of the disk directly sets how fast the cluster can accept changes.

9The Watch Feature: How Kubernetes Reacts Instantly

Instead of asking “has anything changed?” a thousand times, components ask to be told.

Kubernetes works like a set of reactive helpers. The scheduler wants to know when a new pod appears with no home. A controller wants to know when a pod dies. The node agent wants to know when a pod is assigned to its machine. If each of these components repeatedly polled the database, the load would be enormous and the reactions slow.

etcd offers a watch feature. A client says “watch this range of keys and tell me about any change,” and etcd pushes notifications as changes happen. In Kubernetes, the API server holds these watches and shares the news with all the other components, so the cluster feels alive and responsive.

Simple Analogy

Compare refreshing a delivery-tracking page every minute with getting a phone notification when the parcel is near. The notification is faster and takes far less effort. Watches are notifications for the cluster.

Missing nothing

Because every change has a revision number, a watcher that briefly disconnects can say “resume from revision so-and-so” and catch up on what it missed, as long as that history has not been cleaned away. This is one reason etcd is so well suited to controlling a busy system.

10History, Cleaning and Compaction

etcd remembers old versions, which is powerful and also needs housekeeping.

etcd does not overwrite a value in place. When something changes, it records a new version with a higher revision number and keeps the old versions for a while. This design makes watches and consistent reads possible, but the history grows every time anything is updated. In a busy cluster, updates happen constantly, for example every time a node reports its health.

1

Compaction

Removes old history up to a chosen revision, keeping the latest state. Kubernetes normally asks etcd to do this automatically on a regular schedule.

2

Defragmentation

After compaction, the file on disk still has empty gaps. Defragmentation squeezes them out and returns space to the system.

3

Space quota

etcd has a size limit for its database, which by default is a couple of gigabytes. When the limit is hit, it raises an alarm and refuses further writes until the space problem is fixed.

Simple Analogy

A diary that never throws away old pages eventually fills the shelf. Compaction is tearing out pages you no longer need, and defragmentation is repacking the remaining pages so there are no empty gaps.

!
Danger Sign

If etcd hits its space limit, the whole cluster becomes read-only in practice. New pods cannot be created and changes fail. Watching database size is essential.

11Where Does etcd Run? Two Common Layouts

Either alongside the control plane or on its own machines.

Layout 1

Stacked etcd

Each control plane machine also runs an etcd member. Fewer machines and simpler setup, but losing one machine loses both a control plane node and an etcd member.

Layout 2

External etcd

etcd runs on its own dedicated machines, separate from the control plane. More machines and more work, but failures are better isolated and etcd can be tuned separately.

graph TD
  subgraph S["Stacked layout"]
    CP1["Control plane node 1 with etcd"]
    CP2["Control plane node 2 with etcd"]
    CP3["Control plane node 3 with etcd"]
  end
  subgraph X["External layout"]
    A1["API server node 1"]
    A2["API server node 2"]
    A3["API server node 3"]
    E1["etcd member 1"]
    E2["etcd member 2"]
    E3["etcd member 3"]
    A1 --> E1
    A2 --> E2
    A3 --> E3
  end
        
FIG 5 — Stacked and external topologies

With managed Kubernetes services from cloud providers, you usually never see etcd at all. The provider runs, backs up and repairs it for you. Understanding etcd still helps you understand what that service is doing on your behalf and why some limits exist.

12Performance: What Makes etcd Fast or Slow

etcd is small, but it is demanding about a few specific things.

Disk latency

Every commit waits for data to be safely written. Fast solid-state disks are strongly recommended, and sharing the disk with noisy neighbors can cause slow writes and even leader changes.

Network quality

Members must exchange heartbeats and log entries quickly. Delays or packet loss can trigger unnecessary elections, so members are best placed close together, such as in the same region across a few zones.

Memory

etcd keeps its working data in memory for speed, so enough memory prevents slowdowns as the database grows.

Object size and count

Very large objects, or huge numbers of frequently changing objects, put pressure on the database. It is designed for modest-sized configuration records, not bulky data.

Simple Analogy

A court clerk must write each verdict into the official record before announcing it. If the clerk’s pen is slow, every announcement is slow, no matter how quick the judge is. The disk is the clerk’s pen.

13Backup and Restore: Your Safety Net

If etcd is the cluster’s memory, a backup is the cluster’s photograph album.

Having several members protects you from machine failures, but it does not protect you from human mistakes. If someone deletes a namespace by accident, that deletion is faithfully copied to every member. Replication is not a backup. That is why regular snapshots of etcd are vital.

1

Take snapshots on a schedule

Save a snapshot of the database regularly, for example every hour for busy clusters.

2

Store them elsewhere

Keep copies away from the cluster, in another location or storage service, encrypted and access-controlled, since they contain secrets.

3

Practice restoring

Restore into a test environment regularly. A backup you have never restored is only a hope.

4

Know the recovery order

In a real disaster, stop the API servers, restore all members from the same snapshot to form a new etcd cluster, then bring the control plane back.

!
Remember

Restoring rewinds the cluster to the moment of the snapshot. Anything created afterward is gone from the cluster’s records, so restores should be a careful last resort.

14Securing etcd

Whoever controls etcd controls the entire cluster.

Because etcd holds every object and every secret, access to it is equivalent to being the administrator of the whole cluster. Protecting it is one of the most important security tasks.

Layer 1

Encrypted connections

Use TLS for traffic between clients and etcd and between etcd members, so nobody can listen in or impersonate a member.

Layer 2

Client certificates

Only clients holding valid certificates, normally just the API server, should be allowed to connect.

Layer 3

Network isolation

Firewall the etcd ports so only the API servers and other members can reach them.

Layer 4

Encryption at rest

By default Secrets are stored without strong encryption. Kubernetes can encrypt selected objects before saving them, so a stolen disk or backup reveals less.

Layer 5

Protected backups

Snapshots contain everything the live database does, so they need the same level of protection.

Simple Analogy

The master key ledger of a hotel lists every room key. You would lock the ledger in a safe, allow only the manager to read it, and shred old copies. etcd deserves the same care.

15Monitoring etcd Health

Watch the memory of your cluster before it starts forgetting.

etcd publishes many measurements that monitoring tools can collect. A handful of them tell you most of what you need.

Signal 1

Leader stability

Frequent leader changes suggest network or disk trouble. A stable leader is a healthy sign.

Signal 2

Disk sync time

How long it takes to flush changes to disk. Rising times mean slow storage.

Signal 3

Commit latency

How long it takes a majority to confirm a change. High values slow the whole cluster.

Signal 4

Database size

Compared with the space limit, this warns you before writes are blocked.

Signal 5

Member health

Whether every member is reachable and keeping up with the leader.

Signal 6

Failed proposals

A rising count of rejected changes hints at overload or trouble in the group.

Set alerts on these signals so a human is told about slow disks or a filling database long before users notice symptoms such as pods that will not start.

16What Happens When etcd Has Trouble?

Understanding failure modes shows why etcd is so central.

SituationEffect on the clusterWhat to do
One member of three failsCluster continues normally, with less safety marginRepair or replace the member quickly
Leader failsA brief pause while a new leader is elected, then normal serviceCheck why it failed
Majority of members lostWrites stop; the API becomes unable to change anythingRestore members or recover from a snapshot
Database reaches space limitWrites are refusedCompact, defragment and clear the alarm
Disk becomes very slowDelays, timeouts and repeated electionsMove to faster storage
Data corrupted or deletedCluster loses its recordsRestore from a good snapshot

An important point for beginners: when etcd is unavailable, applications already running on the nodes usually keep running for a while, because the node agents continue to look after the containers they already have. What stops is change. You cannot deploy, scale or heal anything until etcd is back. The lights stay on, but nobody can flip a switch.

“etcd is the one component whose loss turns a living cluster into a frozen photograph.”

17Strengths and Limits of etcd

A specialist tool: excellent at its job, unsuitable for others.

Advantages

  • Strong consistency, so every reader sees the agreed truth
  • Survives the loss of a minority of members
  • Efficient change notifications through watches
  • Simple data model that is easy to reason about
  • Small, focused and well tested through years of Kubernetes use
  • Built-in security through TLS and certificate authentication

Disadvantages / Trade-offs

  • Sensitive to slow disks and unreliable networks
  • Limited database size, so it is not a general storage system
  • Writes go through a single leader, so it does not scale writes by adding members
  • Needs care with backups, compaction and defragmentation
  • Loss of quorum halts changes to the whole cluster
i
The Core Trade-off

etcd chooses correctness over availability. When it cannot be sure of the truth, it stops rather than guessing. For a system that controls other systems, this is usually the right choice.

18Good Habits and Bad Habits

Patterns teams follow, and traps they fall into.

Helpful patterns

Odd-sized, spread-out membership

Run three or five members spread across separate failure zones, so a single zone outage still leaves a majority alive.

Dedicated fast storage

Give etcd its own fast disks so other workloads cannot slow it down.

Automated housekeeping and backups

Schedule compaction, defragmentation and snapshots, and alert on failures of those jobs.

Anti-patterns

ANTI-PATTERN-01 Avoid
Problem

Running a production cluster with a single etcd member, or with two members.

Why It’s Harmful

One member has no protection at all. Two members are even more fragile than one, because losing either stops the cluster.

Correct Approach

Use three members at minimum for anything that matters, or choose a managed service that handles this for you.

ANTI-PATTERN-02 Avoid
Problem

Treating replication as a backup and never taking snapshots.

Why It’s Harmful

An accidental deletion or corruption is copied to every member instantly, leaving nothing to go back to.

Correct Approach

Take scheduled, encrypted snapshots stored outside the cluster, and rehearse restoring them.

ANTI-PATTERN-03 Avoid
Problem

Using the cluster database as a dumping ground, storing very large objects or huge volumes of fast-changing data as Kubernetes objects.

Why It’s Harmful

The database grows and slows down, and eventually the whole cluster suffers from delays or a full-disk-style shutdown of writes.

Correct Approach

Keep only cluster configuration in Kubernetes objects and store application data in proper external databases and storage.

19etcd in the Real World

You may already depend on etcd without knowing it.

Managed Kubernetes services

Every major cloud provider’s managed Kubernetes offering has a control plane with a replicated etcd behind it. The provider runs it across several zones, takes backups and handles upgrades so customers rarely think about it.

Self-managed clusters in data centers

Organizations that run their own clusters, for reasons of cost, control or regulation, operate etcd themselves, often on dedicated machines with fast storage and strict access rules.

Edge and small clusters

Lightweight Kubernetes distributions sometimes swap etcd for a smaller storage layer, or run a single-member etcd, trading resilience for a small footprint in places such as shops or factories.

Beyond Kubernetes

Other distributed systems also use etcd to share configuration, elect leaders and coordinate work, because agreement between machines is a problem many systems have.

20Best Practices Checklist

If you remember only a page of this post, remember this one.

1

Run three or five members

Spread them across failure zones and never use an even number.

2

Use fast, dedicated disks

Solid-state storage with low latency is the single biggest performance factor.

3

Automate backups and test restores

Store snapshots off the cluster, encrypted, and rehearse recovery on a schedule.

4

Lock down access

Use TLS, client certificates and firewalls, and enable encryption of Secrets at rest.

5

Monitor and alert

Watch disk sync time, leader changes and database size, and act before limits are reached.

6

Keep versions current

Upgrade etcd and Kubernetes together according to supported version guidance, one step at a time, after testing.

!
Frequent Mistakes

Ignoring database size until writes stop, letting other programs share the etcd disk, opening the etcd port to the wider network, and restoring members from different snapshots.

21Frequently Asked Questions

Q1Is etcd part of Kubernetes or a separate product?

It is a separate open-source project that Kubernetes depends on. Kubernetes ships with instructions and tooling that assume etcd, but etcd is developed on its own.

Q2Can I use Kubernetes without etcd?

The standard Kubernetes control plane expects etcd. Some lightweight distributions replace it with another storage backend, but the role of storing cluster state remains.

Q3Do my application pods talk to etcd?

No. Applications talk to the Kubernetes API if they need cluster information, and only the API server talks to etcd. Applications should never be given direct access to it.

Q4Why is etcd a key-value store and not a regular relational database?

The cluster’s needs are simple: store objects under names, read them back, and be notified of changes. A key-value store with strong consistency and watches does exactly that without the weight of a full relational system.

Q5What is the difference between a leader and a follower?

The leader accepts and orders all changes, while followers copy those changes and stand ready to replace the leader if it disappears.

Q6What is a split brain, and does etcd suffer from it?

Split brain means two groups each believing they are in charge. etcd avoids it because only a group holding a majority can accept changes, and two groups can never both hold a majority.

Q7Why does etcd recommend an odd number of members?

An extra even member adds cost and slows writes without allowing more failures. Odd counts give the best fault tolerance per member.

Q8Are Kubernetes Secrets safe in etcd?

Only if you protect them. By default they are stored in a form that can be decoded easily, so you should enable encryption at rest, restrict access and protect backups.

Q9Do I need to manage etcd on a managed cloud service?

Usually not. The provider operates it. You still benefit from knowing how it works, especially the limits on the number and size of objects.

Q10What is the single most common cause of etcd trouble?

Slow storage. Because every change must be flushed to disk before it is confirmed, poor disk performance leads to slow clusters, timeouts and unstable leadership.

22Summary and Key Takeaways

etcd is the quiet foundation of Kubernetes. It is a small, consistent, distributed database that stores the description and status of everything in the cluster, and it does so in a way that several machines always agree on. Every other component learns the truth from it, through the API server, and reacts to changes through watches. Because so much depends on it, etcd deserves careful sizing, fast disks, strong security, regular backups and steady monitoring.

Key Takeaways

  • It is the cluster’s memory — etcd stores objects, configuration, secrets and state, but not your application’s own data.
  • Only the API server talks to it — this single gateway adds security, validation and load protection.
  • Raft keeps members in agreement — a leader orders changes and a majority must confirm each one before it counts.
  • Quorum shapes sizing — run three or five members, never an even number, and spread them across failure zones.
  • Watches make Kubernetes reactive — components are told about changes instead of asking repeatedly.
  • Housekeeping is essential — compaction, defragmentation and size monitoring prevent the database from filling up and blocking writes.
  • Protect and back it up — encrypt connections and secrets, restrict access and keep tested snapshots, because replication alone is not a backup.