Thursday, December 3, 2026 | London 11°C · Drizzle
DailyGlimpse

AI

Understanding Kubernetes HA: Why kube-apiserver Doesn't Need a Leader But kube-scheduler Does

Technical Cloud Knowledge 3 min read

In Kubernetes high-availability (HA) setups, a common interview question is: why does kube-scheduler (and kube-controller-manager) use leader election, while kube-apiserver does not? Here's the real-time answer.

The Core Difference: Stateless vs. Stateful Components

  • kube-apiserver is stateless. It processes read and write requests against etcd (the cluster's data store) and does not maintain any internal state that requires coordination. Multiple API server instances can run simultaneously, each handling requests independently. etcd itself manages consistency via the Raft consensus algorithm.
  • kube-scheduler and kube-controller-manager are stateful components that perform cluster-level decisions. If multiple schedulers tried to assign pods to nodes concurrently, they would conflict, leading to duplicate assignments or resource overcommitment. Leader election ensures only one instance is active at a time, preventing split-brain scenarios.

Active-Active vs. Leader-Follower Architecture

  • kube-apiserver: Active-Active design. All replicas are active and can serve requests. Traffic is load-balanced across them. This provides high availability and scalability without the overhead of leader election.
  • kube-scheduler and kube-controller-manager: Leader-Follower design. One instance is elected leader and does the actual work; the others stand by. If the leader fails, a new leader is elected. This ensures that only one instance modifies cluster state at a time.

How API Server Handles HA

  • Each API server instance independently talks to etcd. etcd ensures data consistency through its distributed consensus protocol.
  • The API servers cache data locally to speed up read operations, but writes always go through etcd.
  • If an API server fails, the load balancer routes traffic to the remaining healthy instances. No leader election is needed because all instances are identical and stateless.

Why Scheduler Needs Leader Election

The scheduler watches for unscheduled pods and selects a suitable node. If multiple schedulers simultaneously assign the same pod to different nodes, conflicts arise. Leader election serializes scheduling decisions, ensuring each pod is scheduled exactly once.

Why Controller-Manager Needs Leader Election

Controllers (e.g., Deployment controller, ReplicaSet controller) continuously reconcile desired state with actual state. Multiple controller managers acting on the same resources would cause conflicting updates. Leader election ensures only one controller manager performs reconciliation at any time.

Real Production Kubernetes HA Concepts

  • Run multiple API server replicas behind a load balancer (e.g., HAProxy, nginx, cloud LB).
  • Run a single scheduler and controller-manager with leader election (usually 2-3 replicas).
  • etcd must be deployed as a cluster with odd number of members (3, 5) for majority consensus.

Summary

Component Architecture Needs Leader Election? Reason
kube-apiserver Active-Active No Stateless, relies on etcd for consistency
kube-scheduler Leader-Follower Yes Avoids duplicate scheduling decisions
kube-controller-manager Leader-Follower Yes Prevents conflicting controller actions

Understanding this distinction is crucial for designing resilient Kubernetes clusters and for acing DevOps interviews.

React