Docker & Kubernetes
controller-manager
Learn the controllers of kube-controller-manager.
controller-manager
kube-controller-manager runs dozens of controllers in a single process: the Deployment, ReplicaSet, StatefulSet, Job, Node, EndpointSlice, ServiceAccount and Namespace controllers... Each watches its own resource type and moves the actual state toward the desired state. For example:
- The Deployment controller creates ReplicaSets and adjusts their replicas.
- The ReplicaSet controller creates and deletes pods.
- The Node controller marks unresponsive nodes and has their pods evicted.
$ kubectl get pods -n kube-system -l component=kube-controller-manager
NAME READY STATUS
kube-controller-manager-control-plane 1/1 Running
Leader election
In highly available clusters, a controller-manager runs on each control-plane node, but only one is the leader at a time; the others wait. Leadership is held with a Lease object in kube-system and renewed regularly:
$ kubectl get lease -n kube-system kube-controller-manager -o jsonpath='{.spec.holderIdentity}'
cp-2_4f9a1c3e-…
$ kubectl get lease -n kube-system
The same mechanism is used for kube-scheduler and for operators you write yourself.
Exercise Find the leader
Write two commands: list the Lease objects in kube-system; print the holderIdentity value of the kube-controller-manager Lease with jsonpath='{.spec.holderIdentity}'.
Show example solution
kubectl get lease -n kube-system
kubectl get lease kube-controller-manager -n kube-system -o jsonpath='{.spec.holderIdentity}'
Test yourself
-
What happens if a node hasn't responded for 5 minutes?
- The pods wait forever
- The node is deleted
- The node is marked NotReady and its pods are evicted and recreated on other nodes
- The cluster stops
Show answer
The node is marked NotReady and its pods are evicted and recreated on other nodes — The eviction delay is set with taints and tolerationSeconds.
-
List the leadership objects.
kubectl get ____ -n kube-system
Show answer
kubectl get lease -n kube-system
-
Match.
- Deployment denetleyicisi
- Manages ReplicaSets
- ReplicaSet denetleyicisi
- Manages pods
- Node denetleyicisi
- Unresponsive nodes
- Lease
- Leader record
Next lesson: kube-apiserver