Control plane
Leader election
26 / 82

Run several replicas for availability, but let exactly one reconcile.

The controller manager and scheduler use a Lease object as a lock. The holder renews it; if it stops, a standby takes over.

Lease objectkube-controller-managerReplica A (leader)holds and renews the leaseReplica B (standby)watches the leaseReplica C (standby)watches the leaseLeader crashesstops renewingLease expiresa few secondsB acquires itbecomes leader

Compare-and-swap

Replicas try to write their identity into the Lease atomically. Only one succeeds. The leader renews before it expires.

A real, bounded gap

Between a leader dying and a standby taking over, nothing reconciles: no new ReplicaSets, no replacements.

who is leading?
$ kubectl -n kube-system get lease \
    kube-controller-manager -o yaml
holderIdentity: cp-2_5e3b...
leaseDurationSeconds: 15