Kubernetes Operators and CRDs Explained
What Custom Resource Definitions and operators are, how controllers reconcile custom resources, popular operators, and when to build your own.
Published December 2, 2026
Kubernetes knows how to run Deployments and Services, but not how to fail over a PostgreSQL cluster, rotate Kafka certificates or upgrade Elasticsearch safely. Operators teach it. An operator combines a Custom Resource Definition (a new API type) with a controller that encodes the operational knowledge of a human expert into software.
The concept
A Custom Resource Definition (CRD) extends the Kubernetes API with a new kind, for example PostgresCluster with fields like instances, version and backup schedule. Once installed, you create, list and delete these resources with kubectl like built-in ones, and they are stored in etcd and protected by RBAC.
The operator's controller watches those resources and reconciles reality toward them: creating StatefulSets, Services and Secrets, configuring replication, taking backups, performing rolling upgrades, and reporting status back on the resource. The same reconciliation loop that powers Deployments now handles domain-specific operations.
How an operator works
Popular operators
| Operator (examples) | Manages |
|---|---|
| CloudNativePG | PostgreSQL clusters, failover, backups |
| Strimzi | Apache Kafka clusters, topics, users |
| cert-manager | TLS certificates from ACME/CAs |
| Prometheus Operator | Prometheus, Alertmanager, scrape configs |
| External Secrets Operator | Syncing secrets from external managers |
Build or use?
- Is there a mature operator already? Use it
- Is the operational logic complex and recurring? Consider building
- Use a framework (Kubebuilder, Operator SDK, kopf for Python)
- Design the CRD spec/status carefully; version it
- Make reconciliation idempotent and observable
Practical examples
Using an operator's custom resource
A PostgreSQL cluster with CloudNativePG.
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata: { name: orders-db }
spec:
instances: 3
storage: { size: 50Gi, storageClass: fast-ssd }
backup:
barmanObjectStore:
destinationPath: s3://backups/orders-db
s3Credentials: { inheritFromIAMRole: true }Explore CRDs in a cluster
CRDs show up as API resources.
kubectl get crds | head
kubectl api-resources --api-group=cert-manager.io
kubectl explain certificate.specMinimal reconcile in Python with kopf
A toy operator reacting to a custom resource.
import kopf
@kopf.on.create('example.com', 'v1', 'websites')
def create_fn(spec, name, namespace, **_):
# create Deployment + Service for spec['image'] using the Kubernetes client
return {'message': f'website {name} provisioned'}Common mistakes
- Building an operator for something a Helm chart handles fine.
- Non-idempotent reconcile logic that breaks when run repeatedly.
- Installing operators with cluster-admin permissions without review.
- Ignoring CRD versioning and upgrade paths.
Key takeaways
- CRDs add new API types; controllers reconcile them.
- Operators encode expert operations (failover, backups, upgrades).
- Prefer mature community operators.
- Build your own only for complex, recurring operational logic.
FAQ
Is an operator the same as a Helm chart?
No. Helm installs resources once per upgrade; an operator runs continuously and reacts to changes and failures.
Which language are operators written in?
Most use Go with Kubebuilder or Operator SDK, but Python (kopf), Java and others are possible.
Do operators add risk?
They run with significant permissions and become part of your critical path; evaluate maturity, maintenance and RBAC scope.