Skip to main content
In the previous lesson we covered the fundamentals of etcd. In this lesson you’ll learn etcd’s role inside a Kubernetes cluster, how it’s deployed, how to inspect the data it stores, and why high-availability and backups are critical. etcd is the primary datastore for Kubernetes. It stores the cluster’s desired and current state — nodes, Pods, ReplicaSets, Deployments, ConfigMaps, Secrets, ServiceAccounts, RBAC objects (Roles and RoleBindings), and more. When you run kubectl get ..., the apiserver reads that information from etcd. Changes to the cluster (creating a Pod, updating a ConfigMap, adding a Node) are only considered complete once the apiserver persists the change to etcd.
A stylized infographic of a Kubernetes control plane showing a "Master" and an "etcd cluster" on the left, a central list of managed resources (Nodes, Pods, Configs, Secrets, Accounts, Roles, Bindings, Others), and two colorful container ships on the right representing workloads.
etcd is the single source of truth for Kubernetes cluster state. Plan for encryption, secure access, and regular backups — losing or corrupting etcd can render a cluster unrecoverable.

How Kubernetes uses etcd

  • The kube-apiserver reads and writes cluster state to etcd (default client port 2379).
  • All Kubernetes resources are stored under the /registry root key in etcd.
  • Writes must be acknowledged by etcd for operations to be considered complete. This makes etcd critical to cluster consistency.

Common deployment patterns

There are two common approaches for deploying etcd for a Kubernetes control plane: Practice test environments for this course use kubeadm, but understanding both manual and kubeadm-managed deployments is important.

Deploying etcd from scratch (manual installation)

A manual installation typically involves:
  1. Downloading an etcd release and extracting the binaries.
  2. Installing etcd and etcdctl on control-plane nodes.
  3. Creating TLS certificates for client and peer communication.
  4. Configuring a systemd unit to run etcd with appropriate flags (advertised URLs, data directory, initial cluster configuration, etc.).
Example of fetching a release tarball:
Important manual deployment notes:
  • The --advertise-client-urls option sets the endpoint the apiserver and other clients should use (default port 2379).
  • Peer communication between etcd members commonly uses port 2380.
  • TLS is strongly recommended for both client and peer traffic; creating and deploying certificates is a necessary step.

Deploying etcd with kubeadm

When you initialize a cluster with kubeadm, it typically places an etcd pod manifest on the control-plane node so etcd runs as a static pod in kube-system. You can inspect the namespace to find the etcd Pod:
Example (trimmed):
kubeadm-managed etcd still requires you to secure and back up the data; kubeadm bootstraps etcd but does not replace ongoing operational responsibilities.

Exploring etcd data with etcdctl

To explore the etcd keyspace from a kubeadm-managed cluster, execute etcdctl inside the etcd Pod. Use -- after kubectl exec to pass the command into the container:
Notes:
  • If your etcdctl requires API selection or TLS settings, prepend ETCDCTL_API=3 and add --endpoints, --cacert, --cert, and --key flags as needed.
  • Kubernetes stores resources under /registry. Example partial output:
Use careful, read-only exploration when inspecting active clusters — avoid deleting or modifying keys unless you fully understand the consequences.

High-availability etcd clusters

For production, run etcd as a clustered HA service across multiple control-plane nodes so the cluster can tolerate node failures. Key points:
  • Each etcd member must know about other members to form a quorum. This is typically configured with --initial-cluster (or equivalent).
  • Peer URLs (default port 2380) are used for server-to-server communication. Client URLs (default port 2379) are used by the apiserver and other clients.
  • Use secure TLS for both peer and client traffic, and require certificate authentication where possible.
A representative systemd ExecStart for a manual installation:
The --initial-cluster entry lists each member name with its peer URL so members can discover and join the cluster.
In production, ensure regular etcd backups, off-cluster snapshots, and a tested restore process. Loss of etcd data can result in permanent cluster data loss.

Key takeaways

  • etcd is the canonical datastore for Kubernetes cluster state and must be secured and backed up.
  • kubeadm typically runs etcd as a pod for ease of bootstrap; manual deployments give you full control.
  • For HA, run multiple etcd members, configure peer URLs and certificates, and ensure quorum is maintained.
  • Use etcdctl carefully to inspect keys (cluster data lives under /registry) and always use TLS/authentication in production.
Further reading and references: That’s it for this lesson.

Watch Video