Happy Dussehra! May good always win. Merry Christmas! Warm wishes from Vizag. Happy New Year! Here’s to a great year ahead.

DevOps · CNCF daily

CloudNativePG: Kubernetes-Native High Availability for PostgreSQL

CNCF Incubating. A Kubernetes operator that runs PostgreSQL clusters with automated failover, rolling updates, backups to object storage and point-in-time recovery, without external HA tools.

8 min read

CNCF Incubating

  • CloudNativePG
  • PostgreSQL
  • Kubernetes
  • Barman Cloud
  • PgBouncer
CNCF project page

CloudNativePG is a Kubernetes operator that manages the full lifecycle of PostgreSQL clusters: provisioning, replication, failover, rolling updates, backups and recovery. It addresses the long-standing difficulty of running a stateful, primary-standby database on Kubernetes, which previously relied on external high-availability tools such as Patroni, repmgr or Stolon layered onto StatefulSets. EDB built the operator internally as Cloud Native PostgreSQL and released it in May 2022 as an openly governed open source project under the name CloudNativePG. It was accepted into the CNCF at the Sandbox level on January 21, 2025, and moved to Incubating on November 2, 2026 (announced November 10, 2026).

CNCF daily · Sprint 2, day 2 · Database

At a glance

Category App Definition and Development › Database
CNCF status Incubating. Accepted January 21, 2025 (Sandbox); moved to Incubating November 2, 2026
Written in Go
License Apache 2.0
Scope Vanilla PostgreSQL on vanilla Kubernetes; forks and other databases are out of scope
Key resources Cluster, Pooler, Backup, ScheduledBackup, Database, Publication, Subscription, ImageCatalog
Recent milestone 1.28 (December 9, 2025): quorum-based failover stable, PostgreSQL 18 default

Architecture

CloudNativePG architecture: applications connect through an optional PgBouncer pooler to the rw Service for the primary or the ro Service for standbys; the primary streams WAL to standbys and archives WAL and base backups to object storage through the Barman Cloud plugin; the operator reconciles the pods and volumes.

Blue is the client, slate the connection path and the operator, purple the PostgreSQL pods and teal the backup storage. Each instance has its own persistent volume claim, which is not drawn. The operator manages pods and volumes directly rather than through a StatefulSet. Open the zoomable diagram, or download it as SVG or PNG.

Component Responsibility
Applications Connect with ordinary PostgreSQL clients.
Pooler Optional PgBouncer deployment managed by the operator for connection pooling.
Services -rw always points at the primary and -ro at the standbys; failover updates the endpoints. A -r Service points at any instance and is not drawn.
Primary and standbys PostgreSQL pods, each started by the instance manager. The primary streams WAL to the standbys.
Operator Watches Cluster resources and manages pods and persistent volume claims directly, controlling the order of failover, switchover and upgrades.
Object storage Receives continuous WAL archiving and base backups from the Barman Cloud plugin, enabling point-in-time recovery on S3, Azure Blob Storage or Google Cloud Storage.

Design principle. The Kubernetes API is the source of truth for cluster state. Instead of an external consensus system deciding who is primary, the operator and instance managers use Kubernetes resources and status, which keeps the architecture small and observable with standard Kubernetes tools.

A write, its replication and its archive

CloudNativePG flow in eight steps: application to pooler, writes to the rw Service and primary, reads to the ro Service and standby, streaming replication from primary to standby, WAL archiving to object storage, and the operator reconciling the cluster.

  1. Connect. The application sends SQL to the pooler, or directly to a Service.
  2. Route writes. Write connections go to the -rw Service.
  3. Reach the primary. The -rw Service forwards to the current primary.
  4. Route reads. Read-only connections go to the -ro Service.
  5. Reach a standby. The -ro Service forwards to a standby.
  6. Replicate. The primary streams WAL to the standbys.
  7. Archive. The Barman Cloud plugin archives WAL and base backups to object storage.
  8. Reconcile. The operator keeps pods and volumes matching the Cluster, and promotes a standby if the primary fails.

Steps 1 to 5 serve each query; steps 6 to 8 run continuously.

Open the zoomable flow diagram, or download it as SVG or PNG.

Production reference design

A typical deployment on EKS, GKE, AKS or on-premises uses three instances across availability zones, backups to object storage and a pooler in front.

  1. Install the operator with the official Helm chart:
    helm repo add cnpg https://cloudnative-pg.github.io/charts
    helm upgrade --install cnpg cnpg/cloudnative-pg \
      --namespace cnpg-system --create-namespace
    Install cert-manager and the Barman Cloud plugin as well; backups are moving from the operator’s in-tree support to the plugin, and the in-tree implementation is scheduled for removal in a future minor release.
  2. Define the backup target as an ObjectStore, using workload identity (IRSA on EKS) rather than static keys.
  3. Create the cluster, spread across zones, with synchronous replication for zero data loss on failover:
    apiVersion: barmancloud.cnpg.io/v1
    kind: ObjectStore
    metadata:
      name: s3-backups
    spec:
      retentionPolicy: "30d"
      configuration:
        destinationPath: s3://acme-pg-backups/shop
        s3Credentials:
          inheritFromIAMRole: true
        wal:
          compression: gzip
    ---
    apiVersion: postgresql.cnpg.io/v1
    kind: Cluster
    metadata:
      name: shop-db
    spec:
      instances: 3
      imageName: ghcr.io/cloudnative-pg/postgresql:18
      storage:
        size: 100Gi
        storageClass: gp3
      postgresql:
        parameters:
          shared_buffers: "2GB"
          max_connections: "300"
        synchronous:
          method: any
          number: 1
      affinity:
        topologyKey: topology.kubernetes.io/zone
      resources:
        requests: { cpu: "2", memory: 8Gi }
        limits: { memory: 8Gi }
      monitoring:
        enablePodMonitor: true
      plugins:
        - name: barman-cloud.cloudnative-pg.io
          isWALArchiver: true
          parameters:
            barmanObjectName: s3-backups
    ---
    apiVersion: postgresql.cnpg.io/v1
    kind: ScheduledBackup
    metadata:
      name: shop-db-nightly
    spec:
      schedule: "0 0 21 * * *"
      cluster:
        name: shop-db
      method: plugin
      pluginConfiguration:
        name: barman-cloud.cloudnative-pg.io
  4. Add a Pooler with PgBouncer in transaction mode for applications that open many short connections.
  5. Observe with the built-in Prometheus metrics, the community Grafana dashboard and the kubectl cnpg plugin (kubectl cnpg status shop-db).
  6. Rehearse recovery by bootstrapping a new cluster from the object store to a target time, and by running a planned switchover with kubectl cnpg promote.

Typical production uses are application databases for microservices, multi-tenant platforms providing PostgreSQL as a service on Kubernetes, and replica clusters in a second region for disaster recovery.

Operational considerations

  • Scaling: scale reads by adding instances and pointing read traffic at the -ro service; writes scale vertically. Use a Pooler before raising max_connections.
  • High availability: spread instances across zones, use synchronous replication where data loss is unacceptable, and protect pods with the PodDisruptionBudgets the operator creates. Quorum-based failover (stable since 1.28) reduces the risk of promoting a standby that missed committed transactions.
  • Security: TLS is enabled by default with operator-managed certificates; integrate cert-manager for your own CA. Store application credentials in the generated Secrets, rotate them, and restrict pg_hba rules.
  • Cost and sizing: storage performance drives database performance; prefer gp3 or premium SSD classes with provisioned IOPS for busy clusters, and separate WAL volumes for write-heavy workloads.
  • Common pitfalls: untested backups, missing WAL archiving (which blocks point-in-time recovery), node pools without spread across zones, and storage classes that cannot expand volumes. Plan the migration from in-tree Barman backups to the plugin before upgrading to the release that removes them.

Adoption

The project’s end-user page lists organisations including EDB, Tembo, ParadeDB, REWE International AG, Docaposte, Mirakl, Hitachi, the Rubin Observatory and pgEdge, and further adopters are recorded in the repository’s ADOPTERS file. EDB states that the project has dozens of adopters including all major cloud providers, and vendors such as Percona and pgEdge offer support or distributions based on it.

Alternatives

Solution Model Best suited to
Managed PostgreSQL (Amazon RDS and Aurora, Cloud SQL, Azure Database) Fully managed service outside Kubernetes Teams that prefer to buy database operations
Zalando Postgres Operator Operator using Patroni on StatefulSets Existing Patroni users
Crunchy Postgres for Kubernetes (PGO) Operator with Patroni and pgBackRest Organisations wanting Crunchy Data support
StackGres Operator with a web console and integrated stack Teams wanting a bundled UI
Self-managed VMs with Patroni Traditional HA outside Kubernetes Databases intentionally kept off the cluster

Strengths and limitations

Strengths Limitations
No external HA dependency; failover driven by Kubernetes state Running databases on Kubernetes still demands storage and operations expertise
Declarative backups, PITR and replica clusters Incubating since November 2026; governance model and APIs are still evolving
Strong defaults: TLS, metrics, PodDisruptionBudgets Backup architecture is in transition to the plugin model
Active release cadence and broad vendor support Vanilla PostgreSQL only; no support for forks
Plugin interface (CNPG-I) for extensions Write scaling remains vertical, as with any single-primary PostgreSQL

Recommendation

Trial for teams that already run stateful workloads on Kubernetes and want PostgreSQL alongside their applications, especially for on-premises or multi-cloud platforms. Start with a three-instance cluster across zones, the Barman Cloud plugin to object storage, and regular restore drills before moving critical data. Teams without Kubernetes storage experience, or with a managed database already in place, should keep the managed service.

References: CNCF project page · CloudNativePG documentation · Release notes for 1.28 · CNCF Incubating announcement · EDB announcement of the CNCF Sandbox milestone · End users · CloudNativePG on GitHub

Spotted something wrong or out of date?Suggest a correction. I review every suggestion before changing the page.

EmailRSS