KubeBlocks
BlogsEnterprise
⌘K
​
Blogs
Open Source · Production-Grade · CNCF Landscape

KubeBlocks PostgreSQL Operator for Kubernetes

Deploy production-grade PostgreSQL clusters in minutes. Automate high availability with Patroni, WAL-based PITR backups, and minimal downtime upgrades — all through Kubernetes-native APIs.

Get Started Free →Read the Docs

0

Data Loss on Failover (Sync)

99.99%

High Availability Target (3 Replicas)

11+

Pre-installed Extensions

100%

Open Source

Deploy PostgreSQL in 3 steps

1

Install KubeBlocks

# Add Helm repo
helm repo add kubeblocks https://apecloud.github.io/helm-charts
helm repo update

# Install KubeBlocks
helm install kubeblocks kubeblocks/kubeblocks \
  --namespace kb-system --create-namespace
2

Create a PostgreSQL Cluster

apiVersion: apps.kubeblocks.io/v1
kind: Cluster
metadata:
  name: pg-cluster
  namespace: demo
spec:
  terminationPolicy: Delete
  clusterDef: postgresql
  topology: replication
  componentSpecs:
    - name: postgresql
      replicas: 3
3

Check Cluster Status

kubectl get cluster pg-cluster -n demo

NAME        CLUSTER-DEFINITION  STATUS   AGE
pg-cluster  postgresql           Running  2m

Trusted by Engineering Teams at Scale

BONC CloudBONC Cloud
China Mobile CloudChina Mobile Cloud
China Telecom CloudChina Telecom Cloud
TencentTencent
XiaomiXiaomi
Ping AnPing An
VIP.comVIP.com
KwaiKwai
Tiger BrokersTiger Brokers
CITIC SecuritiesCITIC Securities
SealOSSealOS
FastGPTFastGPT
KubeSphereKubeSphere
MomentaMomenta
360360
TilaaTilaa
OlaresOlares
Changan AutomobileChangan Automobile
State GridState Grid
BONC CloudBONC Cloud
China Mobile CloudChina Mobile Cloud
China Telecom CloudChina Telecom Cloud
TencentTencent
XiaomiXiaomi
Ping AnPing An
VIP.comVIP.com
KwaiKwai
Tiger BrokersTiger Brokers
CITIC SecuritiesCITIC Securities
SealOSSealOS
FastGPTFastGPT
KubeSphereKubeSphere
MomentaMomenta
360360
TilaaTilaa
OlaresOlares
Changan AutomobileChangan Automobile
State GridState Grid
PostgreSQL Topology

Patroni HA. Battle-Tested in Production.

KubeBlocks runs PostgreSQL with Patroni for leader election, using the Kubernetes API or a provided etcd as the Distributed Configuration Store.

RTO < 30s
RPO = 0 (Sync)
pgbouncer built-in

One primary with one or more streaming replicas managed by Patroni. Leader election uses a Kubernetes ConfigMap lease or an externally provided etcd. On failure, Patroni automatically promotes the most up-to-date replica and KubeBlocks updates the Kubernetes Service selector to route traffic to the new primary.

✓

Patroni-driven leader election via Kubernetes API

✓

Streaming WAL replication — sync or async configurable

✓

Zero data loss on failover (synchronous commit)

✓

Built-in pgbouncer for connection pooling on :6432

✓

Automatic service endpoint switch on primary change

✓

pg-exporter sidecar for Prometheus metrics on :9187

Application / Client
Read/Write  pg-cluster-postgresql-postgresql:5432
Connection Pool  pg-cluster-postgresql-postgresql:6432 (pgbouncer)
RW traffic → roleSelector: primary
Kubernetes Services
pg-cluster-postgresql-postgresql
ClusterIP · :5432 / :6432
selector: kubeblocks.io/role=primary
Endpoints auto-switch with primary
ReadWrite
→ primary pod only
Pods · Worker Nodes
postgresql-0PRIMARY
postgresql (Patroni)
:5432 pg · :8008 patroni API
leader
pgbouncer
:6432 conn pool
dbctl (role probe)
:5001 /v1.0/getrole
pg-exporter
:9187 metrics
PVCdata-0 · 20Gi
postgresql-1REPLICA
postgresql (Patroni)
:5432 pg · :8008 patroni API
replica
pgbouncer
:6432 conn pool
dbctl (role probe)
:5001 /v1.0/getrole
pg-exporter
:9187 metrics
PVCdata-1 · 20Gi
postgresql-2REPLICA
postgresql (Patroni)
:5432 pg · :8008 patroni API
replica
pgbouncer
:6432 conn pool
dbctl (role probe)
:5001 /v1.0/getrole
pg-exporter
:9187 metrics
PVCdata-2 · 20Gi
↔Streaming Replication (WAL)primary-0 → replica-1 · replica-2  |  sync / async configurable
Headless service — stable pod DNS for internal use (replication, HA heartbeat, operator probes); not a client endpoint
each Patroni agent reads/writes K8s API via :8008
Patroni DCS · K8s API
ConfigMap {scope}-configcluster config · TTL 30s
ConfigMap {scope}leader lease · heartbeat
Secret account-*system account passwords
Poll every 10s · TTL 30s
Leader election via K8s lock
Failover → service re-routes
Primary / RW Traffic
Replica Pod
Patroni DCS (K8s API)
Persistent Storage
Comparison

How KubeBlocks Compares to Other PostgreSQL Operators

FeatureKubeBlocksThisCloudNativePGZalando OperatorCrunchyData PGO
Open Source✓✓✓✓
Patroni-based HA✓
✗

Uses its own HA controller, not Patroni

✓✓
Standby cluster (cross-k8s DR)Enterprise✓~✓
Built-in connection pooler✓✓✓✓
PITR (WAL streaming)✓✓✓✓
Horizontal scaling✓✓✓✓
Minor version upgrade✓✓✓✓
Major version upgrade
Enterprise

Via blue-green deployment

✗~
✓

Via pg_upgrade

TLS in-place rotation✓✓~✓
Prometheus metrics✓✓✓✓
DB / role managementEnterprise✓✓✓
Logical replication management~✓~~
Bootstrap from external PGEnterprise✓~~
Web management UIEnterprise✗✓✓
pgvector / PostGIS support
✓

Pre-installed

✓

Via custom image

✓

Via custom image

✓

Pre-installed

✓ = Supported · ~ = Partial / Limited · ✗ = Not supported

Enterpriseindicates a capability available in KubeBlocks Enterprise, not the open-source distribution. Contact us for licensing →

Based on publicly available documentation. Features may vary by version.

Capabilities

Built for Production PostgreSQL

KubeBlocks automates the hardest parts of running PostgreSQL on Kubernetes — so your team doesn't have to.

Point-in-Time Recovery (PITR)
Continuous WAL streaming + scheduled full backups. Restore to any second in history.
Restore to any second
Backup Timeline
⟵ Continuous WAL Stream ⟶
Full Backup
00:00
Incremental
06:00
Full Backup
12:00
Incremental
18:00
Restore Target
21:37:42
Load Base BackupRestore nearest full snapshot before target time
→
Replay WAL SegmentsApply all transactions up to 21:37:42
→
Cluster ReadyNew PostgreSQL cluster restored to exact point in time
✓ Consistent at restore time
Performance

Kubernetes Doesn't Mean Performance Penalty

Our benchmark shows KubeBlocks-managed PostgreSQL on Kubernetes delivers highly stable performance with zero TPS drops during checkpoints, matching or exceeding bare-metal deployments.

≈ Bare-VM

Throughput (TPS)

KubeBlocks PostgreSQL matches bare-VM throughput — Kubernetes adds no measurable overhead.

0

Kubernetes Performance Tax

With proper parameter tuning, running PostgreSQL on Kubernetes introduces no performance degradation.

Zero

TPS Jitters During Checkpoints

Optimized WAL and filesystem configurations eliminate TPS drops during PostgreSQL checkpoint flushes.

Read Full Benchmark Report →
Day-2 Operations

Every Operation Declared as a Kubernetes Resource

No SSH into pods, no shell scripts. Submit an OpsRequest and KubeBlocks handles the rest.

High Availability & Scaling

✓

Horizontal Scaling

Add or remove replicas online without downtime or reconfiguration.

✓

Vertical Scaling

Resize CPU and memory on running instances with a rolling strategy.

✓

Volume Expansion

Expand PVC storage without pod restarts on supported storage classes.

✓

Rolling Restart

Controlled pod restarts with minimal disruption.

✓

Planned Switchover

Promote a specific replica to primary via Patroni with zero data loss when configured for synchronous replication.

✓

Stop / Start

Suspend clusters to eliminate compute cost; resume with full state.

Configuration, Extensions & Observability

✓

Dynamic Configuration

Tune PostgreSQL parameters via OpsRequest — no restart for supported GUCs.

✓

TLS Encryption

Enable, rotate, or disable in-flight encryption without downtime.

✓

Password Management

Rotate superuser and custom account credentials stored in Kubernetes Secrets.

✓

Minor Version Upgrade

Rolling upgrades across minor PostgreSQL versions with health checks.

✓

pg_exporter Metrics

Per-instance metrics via pg_exporter on :9187, Grafana dashboards included.

✓

Pre-installed Extensions

pgvector, PostGIS, pg_stat_statements, pg_trgm, and 7+ more ready to use.

From the Blog

Go Deeper on PostgreSQL on Kubernetes

PostgreSQL Performance Tuning on Kubernetes: A KubeBlocks Deep Dive

PostgreSQL Performance Tuning on Kubernetes: A KubeBlocks Deep Dive

Benchmark and fix TPS drops, CPU fluctuations, and checkpoint issues by tuning WAL settings, IO bandwidth, and full_page_write.

Managing Over 6,000 Self-Hosted Databases Without a DBA

Managing Over 6,000 Self-Hosted Databases Without a DBA

How Sealos used KubeBlocks to manage 6,000+ self-hosted databases across four availability zones — architecture, HA, backup, and operations.

How Containerization Affects Database Performance: runC, Kata, and gVisor

How Containerization Affects Database Performance: runC, Kata, and gVisor

CPU, memory, and I/O benchmarks across container runtimes — and how to avoid common pitfalls like I/O hangs and OOM errors in Kubernetes.

Get Started

Get Started with KubeBlocks PostgreSQL Operator, Risk-Free.

Open source and production-ready. Enterprise customers get dedicated onboarding, migration support, and SLA guarantees.

Get Started Free →Talk to the Team
✓Open Source
✓PostgreSQL & 30+ other engines
✓Production-grade HA
✓No vendor lock-in

© 2026 KUBEBLOCKS INC