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)

Four-panel comic about Kubernetes operators: Asha runs database failover by hand from a 30-step runbook; an operator is a CRD plus a controller running a watch, compare, act loop; a PostgresCluster with instances: 3 loses its primary, the operator promotes pg-1 and creates pg-3; Asha warns to check what an operator does not do, as the MongoDB Community Operator had no built-in backup or restore.