Kubernetes is excellent at running stateless applications. Tell it you want three replicas of a web server and it will keep three running, restarting or rescheduling them as needed. But what about a PostgreSQL cluster that needs backups, failover and careful version upgrades? Kubernetes does not know how to do those things on its own.
That is the problem Kubernetes Operators solve. An Operator packages the operational knowledge of a human expert into software that runs inside your cluster. This guide explains what Operators are, how they work, where they fit compared to tools like Helm, and when you should use or build one.
What Is a Kubernetes Operator?
A Kubernetes Operator is a method of packaging, deploying and managing an application using Kubernetes' own extension mechanisms. It combines two building blocks:
- A Custom Resource Definition (CRD), which adds a new type of object to the Kubernetes API, such as "PostgresCluster" or "KafkaTopic".
- A custom controller, which watches those objects and takes action to make the real world match what they describe.
With an Operator installed, you can describe a database cluster in a short YAML file (for example, "three instances, version 16, daily backups to object storage") and the Operator handles creating, configuring, backing up, upgrading and healing it.
If you are new to the platform, start with what is Kubernetes and our Kubernetes tutorial for beginners.
The Control Loop: How Operators Work
Everything in Kubernetes runs on the idea of a reconciliation loop. A controller repeatedly compares the desired state (what you declared) with the actual state (what is running) and takes steps to close any gap.
Built-in controllers already do this for Deployments, ReplicaSets and Services. An Operator applies the same pattern to a specific application:
- You create or update a custom resource, for example asking for a database with three replicas.
- The Operator's controller is notified of the change through the Kubernetes API.
- It compares the desired state with what currently exists.
- It performs the required actions, such as creating StatefulSets, Services, Secrets and ConfigMaps, running a database initialisation, or promoting a replica to primary.
- It updates the status of the custom resource so you can see progress, and then keeps watching.
Because the loop runs continuously, Operators can also react to failures. If a primary database pod dies, the Operator can detect it and promote a healthy replica automatically, the way an experienced database administrator would.
Why Use Kubernetes Operators?
- Automating day-2 operations. Installing software is the easy part. Operators handle upgrades, backups, restores, scaling, certificate rotation and failover.
- Consistency. Every team gets the same well-tested process rather than individual scripts and runbooks.
- Declarative management. Complex systems are managed through simple YAML, which fits perfectly with GitOps workflows.
- Self-service. Developers can request a database or message queue by creating a resource, without waiting on a separate operations team. This is a key building block of an Internal Developer Platform.
Operators vs Helm Charts
Helm and Operators are often compared, but they solve different problems.
Helm charts are packages of templated Kubernetes manifests. Helm is very good at installing and upgrading an application with configurable values. Once installed, however, Helm does not watch your application or respond to changes in its state.
Operators run continuously inside the cluster and contain application-specific logic. They manage the full lifecycle, not just installation.
In practice they work together. Many Operators are themselves installed using a Helm chart, and the Operator then manages the application from that point onward. A useful rule: if your application is stateless and only needs installing and configuring, Helm is usually enough. If it needs ongoing expert operational care, look for an Operator.
Operator Capability Levels
The Operator Framework describes five capability levels that help you judge how mature an Operator is:
- Basic install: automated installation and configuration.
- Seamless upgrades: supports upgrading the application and the Operator itself.
- Full lifecycle: manages backups, restores, failure recovery and storage.
- Deep insights: exposes metrics, alerts and logs about the application it manages.
- Auto pilot: automatic scaling, tuning and anomaly detection with minimal human input.
When evaluating an Operator for production, check which level it reaches and how actively it is maintained.
Popular Kubernetes Operators
- Prometheus Operator: manages Prometheus, Alertmanager and monitoring configuration through resources such as ServiceMonitor. Learn the basics in what is Prometheus.
- cert-manager: issues and renews TLS certificates automatically, including from Let's Encrypt.
- CloudNativePG and Zalando Postgres Operator: run highly available PostgreSQL clusters.
- Strimzi: runs Apache Kafka clusters, topics and users on Kubernetes.
- Elastic Cloud on Kubernetes (ECK): deploys and manages Elasticsearch and Kibana; see what is the ELK Stack.
- Crossplane: extends the same pattern to cloud infrastructure, letting you manage cloud resources with Kubernetes objects. Compare it in Terraform vs Crossplane.
OperatorHub.io is a public catalogue where you can browse many community and vendor Operators.
How Operators Are Built
You do not need to write an Operator from scratch. Several frameworks provide the scaffolding:
- Kubebuilder: the Kubernetes SIG project for building Operators in Go.
- Operator SDK: part of the Operator Framework, supports Go, Ansible and Helm-based Operators.
- Kopf: a Python framework, handy for teams more comfortable with Python.
- Java Operator SDK and KubeOps (.NET): options for other language ecosystems.
The usual workflow is to define the API (what fields your custom resource has), generate the CRD, write the reconcile logic, add status reporting, and package the Operator with the right RBAC permissions. Security matters here: an Operator often needs broad permissions, so follow the least-privilege principles in our Kubernetes RBAC guide.
When Should You Build Your Own Operator?
Building an Operator is real software development with ongoing maintenance. Consider it when:
- You run a complex stateful or internal application many times across teams or clusters.
- The operational steps are well understood and repeatable, but currently done manually.
- No suitable, well-maintained Operator already exists.
Avoid it when a Helm chart, a simple CronJob or an existing Operator would do the job. Many teams over-engineer this; the best Operator is often one someone else already maintains.
Best Practices for Using Operators
- Prefer Operators with active communities, regular releases and clear upgrade documentation.
- Pin Operator versions and test upgrades in a staging cluster first.
- Monitor the Operator itself, not just the application it manages.
- Review the permissions an Operator requests before installing it.
- Keep custom resources in Git and deploy them through your normal pipeline.
Conclusion
Kubernetes Operators bring expert operational knowledge into the cluster as code. By combining custom resources with continuous reconciliation, they automate the hardest parts of running stateful and complex software: upgrades, backups, failover and scaling. Start by using proven Operators for databases, certificates and monitoring, and consider building your own only when you have a repeatable operational problem worth automating. For more tooling ideas, see the best Kubernetes tools every DevOps engineer needs.


