2 minute read

The Kube Controller Manager is a Control Plane component that runs and manages multiple Kubernetes controllers.

A controller continuously watches the cluster and works to make the actual state match the desired state.

For example, if we specify that a Deployment should have 3 Pods, a controller makes sure that 3 Pods are running. If one Pod fails, the controller creates another one.

How Controllers Work

Controllers continuously monitor the Kubernetes cluster through the Kube API Server.

        Desired State
             │
             ▼
      Kube API Server
             │
             ▼
        Controller
             │
       Compare states
        ┌────┴────┐
        │         │
      Match    Difference
        │         │
       Done   Take action
                  │
                  ▼
             Actual State

The controller keeps checking the cluster and takes corrective action whenever the actual state differs from the desired state.

Examples of Controllers

Kubernetes has many controllers, each responsible for a specific task.

Node Controller

The Node Controller monitors the health of worker nodes.

It detects when a node becomes unavailable and takes appropriate action, such as marking the node as NotReady and eventually allowing Pods to be rescheduled.

kubectl get nodes

Example:

NAME       STATUS
worker-1   Ready
worker-2   NotReady

Replication Controller / ReplicaSet Controller

Ensures that the required number of Pod replicas are running.

For example:

Desired: 3 Pods

Running:
Pod 1
Pod 2
Pod 3

If one Pod disappears:

Desired: 3 Pods

Running:
Pod 1
Pod 2

The controller creates another Pod to bring the number back to 3.

Other Controllers

Many Kubernetes resources rely on controllers, including:

  • Deployment Controller
  • ReplicaSet Controller
  • StatefulSet Controller
  • DaemonSet Controller
  • Job Controller
  • Namespace Controller
  • Service Controller
  • PersistentVolume Controller
  • Node Controller
  • ResourceQuota Controller

Controller Manager

Instead of running every controller as a separate process, Kubernetes packages many controllers into a single process called the Kube Controller Manager.

              Kube Controller Manager
                       │
       ┌───────────────┼────────────────┐
       │               │                │
       ▼               ▼                ▼
  Node Controller  Deployment       ReplicaSet
                   Controller        Controller
       │               │                │
       └───────────────┼────────────────┘
                       │
                       ▼
                Kube API Server

This makes the controllers easier to deploy and manage.

Enabling and Disabling Controllers

By default, the Controller Manager starts the controllers that are enabled by default.

The --controllers option can be used to control which controllers are enabled or disabled.

For example:

--controllers=*, -tokencleaner

This enables the default controllers while disabling the tokencleaner controller.

High Availability

In a highly available Kubernetes cluster, multiple Control Plane nodes can run the Controller Manager.

The --leader-elect=true option allows multiple Controller Manager instances to coordinate so that only one actively performs controller work at a time.

How to Inspect the Controller Manager

In a kubeadm cluster, the Controller Manager normally runs as a Pod in the kube-system namespace.

kubectl get pods -n kube-system

We can also inspect its configuration in:

/etc/kubernetes/manifests/

For example:

kubectl get pods -n kube-system

Look for:

kube-controller-manager-<node>

On installations where it runs as a system service, we can inspect the running process with:

ps -aux | grep kube-controller-manager

Key Takeaway

The Kube Controller Manager runs Kubernetes controllers that continuously monitor the cluster and take action to maintain the desired state.

It’s like the automation engine of Kubernetes: controllers observe what is happening and correct the cluster whenever its actual state differs from the desired state.