Kubernetes Operators

The operator pattern: a custom controller + CRD that encodes a human operator’s procedural knowledge as a reconcile loop. You declare the end state (Cluster: 3 replicas, HA, backups to S3); the operator continuously compares observed vs desired and executes the transition steps a skilled DBA/sysadmin would — election, failover, backups, upgrades, certificate rotation. It is the control-theory answer to admin work: the same loop as GitOps reconcilers, applied to stateful software instead of manifests.

Why operators matter beyond K8s clusters:

  • The logic is the product — an operator like cloudnative-pg (OSS) (9.4k★) contains the distilled failover/backup/upgrade procedures for PostgreSQL (“automates database operations that a skilled DBA would perform manually”, explicitly replacing Patroni/repmgr/Stolon). That logic is testable, versioned, and reusable as a specification even outside Kubernetes.
  • Reconciliation beats scripts — imperative runbooks drift from reality between runs; a reconcile loop converges on the target from any current state, including states you didn’t anticipate (node died mid-operation).
  • Declarative surface area — the CRD schema is the documented, validated interface. Compare with the average Ansible role’s defaults/main.yml sprawl.

Related: Rewriting Ansible roles from K8s operators (the application of this note) · State machines (a reconcile loop is a statechart with the world as its input event stream) · Infrastructure as Code

Sources: OSS/cloudnative-pg (OSS).md · OSS/mariadb-operator (OSS).md (both captured)