Skip to content
Visual explainer 2h to learn 3 steps

Highly available control plane concepts

Describe stacked vs external etcd topologies and their trade-offs.

By Invicly Tech, , in Kubernetes Administrator (CKA). About 8 minutes to read.

Topic 10 of 33

In short

A highly available control plane runs several API servers behind a load balancer and an etcd cluster with an odd number of members. etcd can be stacked on the control plane nodes or run on separate hosts. etcd needs a majority, or quorum, to accept writes.

Explained simply

A cluster with one control plane node has a single point of failure. If that machine dies, nothing new can be scheduled, scaled or repaired. High availability (HA) means running the control plane on several machines so one failure does not stop the cluster.

It is like a company with three managers instead of one. If one is sick, the other two keep making decisions. But decisions need a majority vote, so with only two managers a single absence would freeze everything. That is why HA setups use odd numbers like three or five.

Two parts need care. The API servers are stateless, so you simply run several and put a load balancer in front. etcd holds the data and must agree on every write, so its size and placement decide how many failures you can survive.

Press Play on a diagram to walk through it one step at a time.

CompareStacked vs external etcd
Stacked etcd
  • etcd on each control plane node
  • Fewer machines to run
  • kubeadm default for HA
  • Losing a node loses etcd and API
External etcd
  • etcd on dedicated hosts
  • Failures are decoupled
  • More hosts to manage
  • Better isolation for large clusters
LayersHA control plane
  1. 1
    Clients and kubelets

    Use the shared control plane endpoint.

  2. 2
    Load balancer

    Spreads TCP 6443 across API servers.

  3. 3
    API servers x3

    Stateless; any can serve any request.

  4. 4
    Scheduler and controllers

    One active leader each, chosen by leader election.

  5. 5
    etcd cluster x3

    Raft consensus; tolerates one member failure.

Compareetcd cluster size and failure tolerance
3 members
  • Quorum: 2
  • Survives 1 failure
  • Common default
  • Lowest cost for HA
4 members
  • Quorum: 3
  • Survives 1 failure
  • More cost, no extra safety
  • Avoid even sizes
5 members
  • Quorum: 3
  • Survives 2 failures
  • For critical clusters
  • Slightly slower writes
SequenceOne write with Raft
API server
etcd leader
Follower A
Follower B
  1. 1Put /registry/pods/web
    API server to etcd leader: Put /registry/pods/web
  2. 2Append entry
    etcd leader to Follower A: Append entry
  3. 3Append entry
    etcd leader to Follower B: Append entry
  4. 4Saved (majority reached)
    Follower A to etcd leader: Saved (majority reached)
  5. 5Committed
    etcd leader to API server: Committed
  6. 6Saved (late, still fine)
    Follower B to etcd leader: Saved (late, still fine)

In depth

How etcd agrees on writes

etcd uses the Raft consensus algorithm. One member is the leader and every write goes through it. The leader sends the write to the followers, and the write is committed only when a majority, called the quorum, has saved it. Quorum is floor(n/2) + 1.

If the leader fails, the remaining members hold an election and pick a new leader within seconds, as long as a majority is still alive. If quorum is lost, etcd stops accepting writes to stay consistent, and the API server cannot change anything. Running Pods keep running, but the cluster is frozen.

  • 3 members: quorum 2, tolerates 1 failure
  • 5 members: quorum 3, tolerates 2 failures
  • 4 members: quorum 3, still tolerates only 1

The shared endpoint

Every kubelet, every kubeconfig and the certificates themselves point at one API address. In HA that address must be a load balancer or a virtual IP in front of all API servers, set at install time with kubeadm init --control-plane-endpoint. Choosing a DNS name rather than a raw IP makes later changes easier.

Adding this endpoint later is painful, because certificates must include it. So even a one-node lab that might grow should be initialised with a control-plane-endpoint.

Joining more control plane nodes

kubeadm init --upload-certs stores the control plane certificates, encrypted, in a Secret in kube-system. It prints a certificate key. Other nodes then run kubeadm join with --control-plane and --certificate-key, download the certificates, and start their own API server, scheduler, controller manager and, in a stacked setup, a new etcd member.

The uploaded certificates are deleted after two hours for safety. To add another control plane later, run kubeadm init phase upload-certs --upload-certs to get a fresh key.

SequenceAdding a second control plane node
First control plane
Secret in kube-system
New node
etcd cluster
  1. 1init --upload-certs: encrypted certs, key printed
    First control plane to Secret in kube-system: init --upload-certs: encrypted certs, key printed
  2. 2join --control-plane --certificate-key
    New node to Secret in kube-system: join --control-plane --certificate-key
  3. 3Certificates downloaded
    Secret in kube-system to New node: Certificates downloaded
  4. 4Add etcd member (stacked setup)
    New node to etcd cluster: Add etcd member (stacked setup)
  5. 5Member joined
    etcd cluster to New node: Member joined

Choosing stacked or external

Stacked etcd runs on the control plane nodes themselves. It needs fewer machines and is the kubeadm default. External etcd runs on its own hosts, so losing a control plane node does not also remove an etcd member, and etcd load does not compete with the API server.

Most teams start stacked with three nodes and move to external etcd only for large or very critical clusters.

Learn it in 3 short steps

About 40m each. Track them with a timer in your plan.

  1. 1
    Compare stacked and external etcd~40m
  2. 2
    Explain load balancing the API servers~40m
  3. 3
    Discuss quorum and failure tolerance~40m

Key points

  • Quorum is a majority: 3 members tolerate 1 failure, 5 tolerate 2.
  • Even member counts add cost without adding failure tolerance.
  • kubeadm init --control-plane-endpoint sets the shared load balancer address.
  • Scheduler and controller manager use leader election, so only one is active.

Key terms

Tap a card to flip it. 0/5 known

Examples

Building a three-node stacked control plane

Step 1: create a load balancer or DNS name k8s-api.lab:6443 pointing at all three nodes. Step 2: init the first node with that endpoint and --upload-certs. Step 3: run the printed control plane join command on nodes two and three. Step 4: check that three etcd and three API server Pods are Running.

bash
sudo kubeadm init --control-plane-endpoint "k8s-api.lab:6443" \
  --upload-certs --pod-network-cidr=192.168.0.0/16
# on cp2 and cp3:
sudo kubeadm join k8s-api.lab:6443 --token <t> \
  --discovery-token-ca-cert-hash sha256:<h> \
  --control-plane --certificate-key <key>
kubectl -n kube-system get pods -l component=etcd -o wide

Reasoning about a failure

A stacked cluster has three control plane nodes and two of them lose power. Step 1: only one of three etcd members is alive, below the quorum of two. Step 2: etcd refuses writes, so kubectl create and scale fail or hang. Step 3: running Pods keep serving traffic. Step 4: bringing back one more node restores quorum and the cluster recovers by itself.

Quick reference

  • Quorum = floor(n/2) + 1; tolerated failures = n - quorum
  • Use 3 or 5 etcd members; even numbers add cost, not safety
  • kubeadm init --control-plane-endpoint LB:6443 --upload-certs
  • kubeadm join ... --control-plane --certificate-key KEY
  • Uploaded certs expire after 2 hours: kubeadm init phase upload-certs --upload-certs
  • Scheduler and controller manager are active-passive via Leases

Common mistakes

  • Running two etcd members, which tolerates zero failures.
  • Pointing kubelets at one API server instead of the load balancer.

Quick quiz

Pick an answer to see if you're right and why.

Question 1

1A 5-member etcd cluster loses 3 members. What happens?

Question 2

2Why should you set --control-plane-endpoint even for a single control plane lab you may grow later?

Question 3

3What is the main benefit of external etcd over stacked etcd?

Question 4

4In an HA cluster, how many kube-scheduler instances actively schedule Pods at once?

0/4 answered

Practice exercises

Try each one yourself first. Use the hint if you get stuck, then compare with the solution.

  1. Exercise 1easy

    Fill in the table: for 1, 3, 5 and 7 etcd members, what is the quorum and how many failures are tolerated?

  2. Exercise 2medium

    On a stacked HA cluster, list the etcd members using etcdctl from one control plane node.

  3. Exercise 3hard

    Your three-node HA cluster's uploaded certificates expired and you need to add a fourth control plane node. Get a working join command.

Check yourself

Answer in your head, reveal, then be honest with yourself.

Feel confident about this topic?

Frequently asked questions

Do I need HA for the CKA exam?
You will not usually build one, but you must explain stacked vs external etcd, quorum, and how the load balancer fits in.
Can etcd members be in different data centres?
Yes, but every write waits for a majority, so high latency between sites slows the whole cluster. Keep members within low-latency links, such as zones in one region.
What load balancer should I use for the API servers?
Any TCP load balancer works: a cloud load balancer, HAProxy with keepalived, or kube-vip. It only needs to forward port 6443 to healthy API servers.

Go deeper

ShareXLinkedInWhatsApp