Introducing Zalando’s Postgres Operator: Infrastructure-as-Code for HA PostgreSQL on Kubernetes
The Zalando Postgres Operator enables easy deployment of high‑availability PostgreSQL clusters on Kubernetes using Patroni, managed entirely through CRDs, supporting rolling updates, sidecar monitoring, and seamless CI/CD integration without direct API calls.
Postgres Operator provides easy‑to‑run high‑availability PostgreSQL clusters on Kubernetes (K8s) backed by Patroni. It is configured solely via PostgreSQL CRDs, allowing smooth integration into CI/CD pipelines without direct access to the Kubernetes API, thus enabling true infrastructure‑as‑code.
Operator Features
Postgrescluster rolling updates, including fast minor version upgrades.
Resize live volumes (AWS EBS, PVC) without restarting pods.
Database connection pooling with PGBouncer.
Fast upgrades to PG13 and global cluster upgrades.
Restore and clone PostgreSQL clusters, including major version upgrades.
Logical backups to S3 buckets.
Standby clusters from S3 WAL archives.
Configurable for non‑cloud environments.
K8s basic credential and user management to simplify app deployment.
Custom TLS certificate support.
Create and edit PostgreSQL cluster manifests via a UI.
Runs well on Amazon AWS, Google Cloud, OpenShift, and Kind.
Supports migration of AWS EBS gp2 to gp3 with configurable IOPS and throughput.
PostgreSQL Features
Supports PostgreSQL 14 and versions 9.6+.
Streaming replication clusters managed by Patroni.
Point‑In‑Time Recovery using Spilo with pg_basebackup / WAL‑E.
Pre‑loaded extensions: bg_mon, pg_stat_statements, pgextwlist, pg_auth_mon.
Popular extensions such as decoderbufs, hypopg, pg_cron, pg_partman, pg_stat_kcache, pgq, plpgsql_check, postgis, set_user, and timescaledb.
The operator has been developed by Zalando and has been in production for over three years, managing large numbers of PostgreSQL clusters across staging and production environments.
Using Spilo 12 or Older Images
If you are using older Spilo 12 Docker images with the Postgres operator, note that the backup path has changed to include the major version, facilitating smooth major version upgrades. The new operator configuration offers a compatibility flag enable_spilo_wal_path_compat that allows Spilo to look for WAL segments in both the new and old paths, at a potential performance cost, and should be disabled after a few days.
Current Spilo images:
Latest: registry.opensource.zalan.do/acid/spilo-14:2.1-p4 Oldest:
registry.opensource.zalan.do/acid/spilo-12:1.6-p5Getting Started
For a quick first impression, follow the quick‑start guide:
https://github.com/zalando/postgres-operator/blob/master/docs/quickstart.mdSupported Postgres and Application Settings
Concepts
The Postgres operator monitors PostgreSQL cluster CRDs for additions, updates, and deletions, generating the necessary K8s StatefulSets and PostgreSQL roles. When a new manifest is submitted, the operator creates a new PostgreSQL cluster and associated resources. It also watches its own configuration and performs rolling updates of pods when the Docker image changes, ensuring each StatefulSet pod is regenerated with the new image.
While the operator does not monitor PostgreSQL itself, a configurable sidecar allows integration with tools such as ZMON or Prometheus for additional monitoring.
Scope
The operator’s scope is to provide, modify, and clean up Patroni‑based PostgreSQL clusters on K8s, handling both K8s resources and database/role configuration after cluster boot. It also performs orchestration tasks like rolling updates to improve user experience.
Status
The project is actively developed. Zalando uses it internally to run many PostgreSQL clusters on multiple K8s clusters for staging and production, deploying the operator via CI/CD manifests or a streamlined UI.
Report any issues at https://github.com/zalando/postgres-operator/issues.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
