Services

Resources

Company

Kubernetes operator

A Kubernetes operator is software that runs inside the cluster and manages one specific application, such as PostgreSQL, Kafka or MongoDB. It extends the Kubernetes API with a custom resource, defined by a custom resource definition (CRD), and runs a controller that does what an experienced engineer would: create replicas, run failover, roll out upgrades and resize storage.

How it works

You apply a custom resource that describes the application, for example kind: PostgresCluster with instances: 3. The operator's controller watches these resources, compares them with what is running, and acts on the difference.

If the primary database pod dies, the operator promotes a replica and creates a new third instance, the same steps a person would follow from a runbook, without waiting for someone to be paged.

Why it matters in production

Operators differ widely in what they automate. Some handle backups, restores and major version upgrades; others only create the cluster. Read what an operator does not do before relying on it. On one GKE project, the MongoDB Community Operator had no built-in backup or restore, so One2N built the disaster recovery around it.

See also

On the One2N blog

References

  1. Operator pattern (Kubernetes documentation)

  2. Custom resources (Kubernetes documentation)

Comic about Kubernetes operator: Asha applies a PostgresCluster custom resource and the operator builds three pods; the primary dies at 03:10 and the operator promotes a replica and adds a new one with no page; editing the image field drives a rolling upgrade, with a note to check what an operator skips.