Introduction
Crunchy PGO (Postgres Operator) is a Kubernetes operator that manages the full lifecycle of PostgreSQL clusters. It handles provisioning, high availability with automatic failover, backups via pgBackRest, and day-two operations like scaling and minor version upgrades, all declared through Kubernetes custom resources.
What Crunchy PGO Does
- Deploys PostgreSQL clusters on Kubernetes with a single custom resource definition
- Manages high availability using Patroni-based leader election and automatic failover
- Automates full, incremental, and differential backups with pgBackRest
- Handles connection pooling through integrated PgBouncer sidecar containers
- Supports cloning, point-in-time recovery, and standby cluster creation
Architecture Overview
PGO runs as a controller in the Kubernetes control plane. It watches PostgresCluster custom resources and reconciles the desired state by creating StatefulSets, Services, ConfigMaps, and Secrets. Each PostgreSQL instance runs in its own pod with Patroni managing replication and failover. pgBackRest runs as a dedicated repository host pod, storing backups on PVCs or S3-compatible object storage. PgBouncer pods provide connection pooling between applications and the database.
Self-Hosting & Configuration
- Install the operator using Kustomize or Helm into any Kubernetes cluster
- Define clusters declaratively via the PostgresCluster CRD in YAML
- Configure backup schedules and retention policies in the pgbackrest section of the spec
- Scale replicas by updating the instances.replicas field and applying the manifest
- Store backups on local PVCs, AWS S3, Google Cloud Storage, or Azure Blob Storage
Key Features
- Automated failover with zero-downtime leader election via Patroni
- Built-in pgBackRest integration for continuous archiving and point-in-time recovery
- PgBouncer connection pooling managed as part of the cluster lifecycle
- TLS encryption for client connections and inter-node replication
- Monitoring integration with Prometheus via the crunchy-postgres-exporter sidecar
Comparison with Similar Tools
- CloudNativePG — similar Kubernetes-native operator; PGO has longer history and Crunchy Data commercial backing
- Zalando Postgres Operator — uses Patroni like PGO but with a different CRD design and Spilo images
- KubeDB — supports multiple databases; PGO is PostgreSQL-focused with deeper Postgres integration
- Pigsty — Ansible-based for VMs; PGO is purpose-built for Kubernetes environments
- Amazon RDS — managed service; PGO gives full control on your own Kubernetes infrastructure
FAQ
Q: Does PGO support major PostgreSQL version upgrades? A: PGO supports minor version upgrades through rolling updates. Major version upgrades require creating a new cluster and migrating data using pg_dump/pg_restore or logical replication.
Q: Can I use PGO with an existing PostgreSQL database? A: PGO provisions new clusters. To adopt an existing database, you would restore a pgBackRest backup or pg_dump into a PGO-managed cluster.
Q: How does automatic failover work? A: Patroni monitors the primary and replicas. If the primary becomes unreachable, Patroni promotes a replica and PGO updates the Kubernetes Service endpoints so applications reconnect automatically.
Q: Is PGO free to use? A: Yes. PGO is open source under the Apache 2.0 license. Crunchy Data offers commercial support and a certified distribution for enterprise customers.