PostgresCluster. Patroni continuously monitors all instances, holds a leader election using Kubernetes Endpoints as its distributed configuration store, and promotes a replica to primary within seconds if the current primary becomes unhealthy — all without operator intervention. This page explains how to configure multiple replicas, control scheduling, tune Patroni behavior, and set up cross-cluster standby clusters.
Run multiple instances
Addreplicas to an instance set to create a primary plus one or more streaming replicas. For three-node HA, set replicas: 3.
replicas: 3, PGO creates one primary and two hot standbys. Replicas are readable via the replica Service (hippo-replicas) and can absorb read traffic.
A minimum of three nodes (or three replicas) provides quorum and prevents split-brain scenarios. With only two instances, Patroni cannot safely elect a new primary if the old one becomes unreachable.
Multiple instance sets
You can define multiple instance sets to place groups of instances on different node pools, availability zones, or storage classes. Each set is an independentStatefulSet but all share the same Patroni cluster.
Pod anti-affinity
To survive a node or availability zone failure, spread replica pods across failure domains using affinity rules or topology spread constraints.- Pod anti-affinity
- Topology spread constraints
This rule prevents two instances from landing on the same Kubernetes node by using
requiredDuringSchedulingIgnoredDuringExecution.Patroni configuration
spec.patroni exposes key Patroni tuning parameters.
Dynamic configuration
spec.patroni.dynamicConfiguration passes arbitrary Patroni dynamic configuration that is reloaded at runtime without a rolling restart. This is the correct way to configure synchronous replication.
Check cluster status
1
List all instance pods
2
Identify the current primary
The Patroni leader pod carries the label
postgres-operator.crunchydata.com/role=master.3
Query Patroni REST API
Exec into any instance pod and call the local Patroni API for detailed cluster state:
Switchover (planned failover)
A switchover gracefully promotes a healthy replica and demotes the current primary. Use this for planned maintenance, node drains, or testing your failover path.1
Enable switchover in the spec
2
Trigger the switchover
Apply the updated manifest. PGO reconciles the
switchover section and issues the Patroni switchover request. To target a specific instance:3
Verify the new primary
4
Disable switchover after it completes
Set
enabled: false or remove the switchover block to prevent unintended re-triggering.Standby clusters
A standby cluster runs as a read-only copy of another PostgresCluster. It continuously applies WAL from a pgBackRest repository and can be promoted to an independent primary — ideal for cross-cluster disaster recovery or blue/green deployments.standby.enabled: false and apply the manifest. PGO will stop WAL replay and allow the cluster to accept writes.
Minimum available pods
UseminAvailable to configure the PodDisruptionBudget for each instance set. This protects against simultaneous voluntary disruptions (node drains, upgrades) taking down too many replicas at once.
Create a cluster
Configure the base PostgresCluster spec.
Backups
Set up pgBackRest for scheduled and on-demand backups.
Disaster recovery
Restore from backup and bootstrap standby clusters.
Custom Resource Reference
Full field reference for
spec.patroni and spec.instances.