A logo showing the text blog.marcnuri.com
Español
Home»Operations»Kubernetes Operator vs. Controller

Recent Posts

  • Fabric8 Kubernetes Client 7.2 is now available!
  • Connecting to an MCP Server from JavaScript using AI SDK
  • Connecting to an MCP Server from JavaScript using LangChain.js
  • The Future of Developer Tools: Adapting to Machine-Based Developers
  • Connecting to a Model Context Protocol (MCP) Server from Java using LangChain4j

Categories

  • Artificial Intelligence
  • Front-end
  • Go
  • Industry and business
  • Java
  • JavaScript
  • Legacy
  • Operations
  • Personal
  • Pet projects
  • Tools

Archives

  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • August 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • February 2020
  • January 2020
  • December 2019
  • October 2019
  • September 2019
  • July 2019
  • March 2019
  • November 2018
  • July 2018
  • June 2018
  • May 2018
  • April 2018
  • March 2018
  • February 2018
  • December 2017
  • July 2017
  • January 2017
  • December 2015
  • November 2015
  • December 2014
  • March 2014
  • February 2011
  • November 2008
  • June 2008
  • May 2008
  • April 2008
  • January 2008
  • November 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007

Kubernetes Operator vs. Controller

2020-11-06 in Operations tagged Kubernetes / Operators / Controllers / DevOps / OpenShift by Marc Nuri | Last updated: 2025-01-29
Versión en Español

Introduction

The terms Kubernetes Operator and Kubernetes Controller are often used interchangeably or misunderstood, leading to confusion among developers and operators alike. While both are integral to Kubernetes' extensibility and automation capabilities, they serve distinct purposes.

In this post, I’ll clarify the differences between these two patterns, highlight their use cases, and provide updated examples to help you better understand their roles in modern Kubernetes environments.

Kubernetes Controllers

Kubernetes Controllers are the backbone of its declarative model. They implement a control loop, a concept borrowed from industrial control systems, where they continuously monitor the cluster's state and reconcile it with the desired state defined in resource specifications.

Tip

A control loop is the fundamental building block of industrial control systems.

It consists of all the physical components and control functions necessary to automatically adjust the value of a measured process variable (PV) to equal the value of a desired set-point (SP).

A Kubernetes Controller is a control loop that monitors the state of cluster resources and takes action to bring them to a desired state. According to the Kubernetes documentation, controllers follow this pattern:

  1. Observe the current state of cluster resources.
  2. Compare it with the desired state defined in a Kubernetes object’s spec.
  3. Act to reconcile the differences, if necessary.

Examples of Built-in Controllers

  • ReplicaSet Controller: Ensures that the number of Pods matches the desired replicas specified in a ReplicaSet.
  • StatefulSet Controller: Manages stateful applications by ensuring ordered deployment and scaling.
  • DaemonSet Controller: Guarantees that a Pod runs on all (or specific) nodes in a cluster.

Custom use cases

Controllers aren't limited to built-in resources. Developers can create custom controllers for specific needs:

  • Annotation Controller: Ensures that all Pods are annotated with a specific value. The controller monitors Pod resources and automatically adds the annotation to all Pods upon creation or modification. For example, the controller could automatically add the annotation controlled-by: dumb to all Pods.
  • Service Enforcement Controller: Deletes any Service resources that are of type NodePort. The controller monitors Service resources and deletes any Service created or modified to be of NodePort type.

These examples demonstrate that a Controller's primary focus is enforcing a desired state, regardless of whether it involves built-in or custom logic.

Kubernetes Operators

A Kubernetes Operator is a specialized controller that extends Kubernetes APIs using Custom Resource Definitions (CRDs) to manage complex applications. The term was coined by CoreOS and has since evolved into a core pattern in Kubernetes.

Operators essentially act as "human operators" codified into software. They automate tasks that would traditionally require manual intervention by an administrator.

Key characteristics of an Operator

  • Uses the controller pattern to reconcile state.
  • Extends the Kubernetes API with CRDs to introduce new resource types.
  • Encodes operational knowledge to automate tasks such as backups, upgrades, and scaling.
  • Manages a single application and its lifecycle. Unlike generic controllers, Operators are application-specific and focus on managing a single application or component.

Examples of Operators

  • Strimzi Operator: Manages Apache Kafka clusters on Kubernetes.
  • Prometheus Operator: Deploys and manages Prometheus monitoring instances.
  • PostgreSQL Operator: Automates the deployment and management of PostgreSQL databases.

Operators are commonly built using the Operator SDK and deployed with the Operator Lifecycle Manager (OLM).

When to use a Controller vs. an Operator

A basic Controller may be sufficient if:

  • Your automation only requires watching built-in Kubernetes resources.
  • Your logic does not require a new API abstraction.

Use an Operator when:

  • You need to introduce a new resource type specific to your application.
  • The application requires domain-specific operational knowledge, such as upgrades, scaling, and failover handling.
  • You want to provide users with a Kubernetes-native experience for managing the application.

Conclusion

All Operators are controllers, but not all controllers are Operators. Controllers focus on enforcing Kubernetes-native behaviors, while Operators extend Kubernetes to manage complex applications with domain-specific knowledge.

While controllers can be written in any language, using frameworks like the Operator SDK simplifies development and reduces boilerplate code. Understanding when to use a controller versus an Operator can help developers build better automation solutions for Kubernetes workloads.

References

  • Stack Overflow: What is the difference between a Kubernetes Controller and a Kubernetes Operator?
  • Kubernetes.io:
    • Controllers
    • Operators Pattern
  • GitHub: [Discussion] Operators vs. controller pattern
  • CoreOS: Operators
  • InfoQ: Kubernetes Operators in Depth
Twitter iconFacebook iconLinkedIn iconPinterest iconEmail icon

Post navigation
YAKC – Kubernetes DashboardA year at Red Hat
© 2007 - 2025 Marc Nuri