DEV Community

Aisalkyn Aidarova
Aisalkyn Aidarova

Posted on

A controller in Kubernetes is a control loop that:

  • Watches the current state of the cluster (from the API server),
  • Compares it with the desired state (from YAML manifests),
  • Acts to fix differences (create/update/delete resources).

Example:

You define “3 Pods” → if only 2 are running, the controller starts 1 more.


🧩 2. Main Categories of Controllers

There are 3 broad categories:

Category Description Examples
Workload Controllers Manage Pods and how applications run. Deployment, ReplicaSet, StatefulSet, DaemonSet, Job, CronJob
Infrastructure Controllers Manage nodes, networking, namespaces, etc. Node Controller, Service Controller, Namespace Controller
Custom / Operator Controllers Created by users to manage specific apps or CRDs. Prometheus Operator, Argo CD Operator, AWS Controllers for Kubernetes (ACK)

⚙️ 3. Core Workload Controllers (Most Common)

These are the controllers you’ll use daily.

Controller Purpose Typical Use Case
Deployment Manages ReplicaSets and performs rolling updates/rollbacks. Stateless web apps, APIs
ReplicaSet Ensures a specific number of identical Pods are running. Low-level controller used by Deployment
StatefulSet Ensures unique, ordered Pods with stable storage and network IDs. Databases (MySQL, MongoDB), Kafka, Zookeeper
DaemonSet Ensures one Pod runs on each node (or selected nodes). Log collectors, monitoring agents (Prometheus Node Exporter, Fluentd)
Job Runs Pods to completion. Batch tasks, data processing
CronJob Runs Jobs on a schedule. Backups, cleanup jobs, periodic reports

🏗️ 4. Cluster & Infrastructure Controllers

These are system-level controllers running in the kube-controller-manager (on the control plane).

Controller Description
Node Controller Detects when nodes go down and manages node lifecycle.
Service Controller Creates or removes cloud load balancers when Services of type LoadBalancer are created.
Namespace Controller Cleans up resources when a namespace is deleted.
EndpointSlice Controller Maintains network endpoints for Services efficiently.
PersistentVolume Controller Manages PersistentVolume and PersistentVolumeClaim binding.
PersistentVolumeBinder Handles dynamic provisioning of storage.
ServiceAccount Controller Creates default service accounts and API tokens.
ReplicationController (Legacy) Older controller replaced by ReplicaSet.
Job Controller Manages Pod creation for Job resources.
CronJob Controller Manages Job scheduling for CronJobs.

All these run inside one process:

kube-controller-manager
Enter fullscreen mode Exit fullscreen mode

🧰 5. Cloud-Specific Controllers (on Managed Clusters)

When you use EKS, GKE, or AKS, additional controllers integrate Kubernetes with the cloud provider:

Controller Role
Cloud Controller Manager Connects Kubernetes with the underlying cloud APIs.
Route Controller Manages networking routes between cluster nodes.
AWS Load Balancer Controller Provisions AWS ALB/NLB for Ingress or Services.
External DNS Controller Automatically manages DNS records in Route53 or Cloud DNS.

🧬 6. Custom Controllers

Developers can create their own controllers to automate any workflow.

Example:
You define a Custom Resource Definition (CRD) called Database, and a custom controller ensures that:

  • When a Database object is created → a Pod and PVC are provisioned.
  • When it’s deleted → resources are cleaned up.

This is how Operators are built.


🧠 7. Operator Controllers (Advanced)

Operators are custom controllers that encode domain-specific operational logic.

Example Operator What It Manages
Prometheus Operator Deploys and configures Prometheus and Alertmanager
Argo CD Operator Manages Argo CD GitOps setup
Kafka Operator Manages Kafka clusters
PostgreSQL Operator Automates PostgreSQL database deployment
AWS Controllers for Kubernetes (ACK) Manages AWS resources (S3, RDS, etc.) directly from Kubernetes

Operators use:

  • Custom Resources (CRDs)
  • Custom Controllers (logic)
  • Often written in Go, Python, or with frameworks like Kubebuilder.

🧮 8. Summary Table — All Controller Types

Type Example Controllers Purpose
Workload Controllers Deployment, StatefulSet, DaemonSet, Job, CronJob Manage Pods and app workloads
System Controllers Node, Namespace, Service, Endpoints, PV/PVC Maintain cluster infrastructure
Cloud Controllers AWS Load Balancer, Route, Cloud Controller Manager Integrate with cloud provider
Custom Controllers CRD-based logic Extend Kubernetes
Operators Prometheus Operator, Argo CD Operator Automate complex apps

🧩 9. Where They Run

All default controllers (like Deployment, StatefulSet, etc.) are part of the kube-controller-manager process on the control plane.

Custom and Operator controllers run as Pods inside the cluster.


🧠 10. How to See Active Controllers

You can check which controllers are running:

kubectl get pods -n kube-system | grep controller
Enter fullscreen mode Exit fullscreen mode

You might see:

kube-controller-manager-minikube
aws-load-balancer-controller-xxxx
ingress-nginx-controller-xxxx
Enter fullscreen mode Exit fullscreen mode

Top comments (0)