Services

Resources

Company

/

Kubernetes operator

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 Google Kubernetes Engine (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)

Reconcile loop of a Kubernetes operator. A desired custom resource, kind PostgresCluster with instances: 3, and the running cluster, with 2 of 3 pods, both feed a watch step. Watch leads to compare, which finds 3 versus 2, then to act, which promotes a replica and adds a pod to the cluster. Below, green boxes list replicas, failover and upgrades; a red box reads "no backup", not in every operator.

Putting this into practice?

Talk to One2N about our platform engineering services

Talk to One2N about our platform engineering services