Kube Controller Manager: A Quick Guide

👋 Hi! I’m Bibin Wilson. In each edition, I share practical tips, guides, and the latest trends in DevOps and MLOps to make your day-to-day DevOps tasks more efficient. If someone forwarded this email to you, you can subscribe here to never miss out!

To understand Controller Manager, first you should know what a controller is.

What Is a Controller Pattern?

As per the official documentation:

"In Kubernetes, controllers are control loops that watch the state of your cluster, then make or request changes where needed. Each controller tries to move the current cluster state closer to the desired state."

The Controller pattern is a fundamental design concept in Kubernetes.

The controller pattern involves a continuous control loop that monitors the state of the cluster and makes adjustments to reach the desired configuration specified by the user.

The pattern follows a simple principle: Watch -> Analyze -> Act

The following are the key components of the controller pattern.

  • Desired State: This is the configuration you define for your Kubernetes resources. It includes specifications like the number of pod replicas, resource allocations, network policies, and more.

  • Actual State: The real-time status of resources in your cluster. This is what is currently running and how resources are actually configured.

  • Reconciliation Loop: Controllers run an infinite loop where they compare the desired state to the actual state. If discrepancies are found, the controller takes corrective actions to reconcile them.

So what is a controller?

Controllers are programs that run continuous loops, constantly monitoring the state of your cluster.

Here is how the controller works.

  1. The controller watches for changes in resource objects by subscribing to events from the Kubernetes API server.

  2. It compares the current state of the resource with the desired state defined by the user.

  3. If there's a difference, the controller makes the necessary API calls to adjust the resources, such as creating new pods, updating configurations, or deleting obsolete resources.

A Real-World Example: Deployments

Let's say you deploy an application and specify that you want 2 replicas of a particular pod running.

You define this desired state in a manifest file, including details like volume mounts and config maps. The Deployment Controller, which is one of Kubernetes' built-in controllers, takes this manifest and ensures that there are always two replicas running.

Now, if you decide to scale up and update the deployment to have 5 replicas, the Deployment Controller notices this change. It then works to create the additional pods needed, ensuring that the actual state (5 running replicas) matches your new desired state.

What Is the Kube-Controller-Manager?

The kube-controller-manager is essentially the brain that oversees all these controllers.

It's a core component of the Kubernetes control plane that runs controllers in a single process to simplify management.

The following is the list of important built-in Kubernetes controllers.

  1. Deployment controller

  2. Replicaset controller

  3. DaemonSet controller 

  4. Job Controller

  5. CronJob Controller

  6. endpoints controller

  7. namespace controller

  8. service accounts controller.

  9. Node controller

Reply

or to participate.