The kube-controller-manager is a control plane component that runs multiple controller processes in a single binary for simplicity. Think of it as the "operator" that continuously monitors the cluster state and makes changes to move the current state toward the desired state.
Here are the key controllers it manages:
Node Controller:
- Monitors node health through the kubelet
- Notices when nodes go down and evicts pods if needed
- Maintains an accurate count of available nodes
Replication Controller:
- Ensures the correct number of pod replicas are running
- Creates or deletes pods as needed to maintain the desired count
Endpoints Controller:
- Populates the Endpoints object (links Services to Pods)
- Creates the mapping between Services and the Pods that back them
Service Account & Token Controllers:
- Creates default accounts and API access tokens for new namespaces
- Manages service account credentials for pods
Job Controller:
- Watches for Job objects that represent one-off tasks
- Creates pods to run jobs and tracks completion
CronJob Controller:
- Creates Jobs on a time-based schedule (like cron)
Deployment Controller:
- Manages Deployment objects and their ReplicaSets
- Handles rolling updates and rollbacks
StatefulSet Controller:
- Manages StatefulSet objects for stateful applications
- Guarantees ordering and uniqueness of pods
DaemonSet Controller:
- Ensures specified nodes run a copy of a pod
- Used for node-monitoring, log collection, etc.
PersistentVolume Controller:
- Provisions storage based on PersistentVolumeClaims
Namespace Controller:
- Cleans up resources when namespaces are deleted
ResourceQuota Controller:
- Enforces resource consumption limits per namespace
Each controller implements a control loop that:
- Observes the current state through the API server
- Compares it to the desired state
- Makes necessary changes to reach the desired state
- Repeats continuously
By combining these controllers into a single process, Kubernetes simplifies deployment while maintaining a separation of concerns in the codebase. Each controller is focused on a specific responsibility, following the "do one thing well" Unix philosophy.