Release notes for CloudNativePG 1.31
History of user-visible changes in the 1.31 minor release of CloudNativePG.
For a complete list of changes, please refer to the commits on the release branch in GitHub.
Version 1.31.0-rc1
Release date: Nov 25, 2026
Important changes
Each change below has a section in "Upgrading to 1.31.0" in the documentation.
-
CONNECTis revoked fromPUBLICon the databases created by the operator: new clusters and new databases no longer accept connections from every role. The operator revokesCONNECTfromPUBLIConpostgres,template1, and the application database of a cluster bootstrapped withinitdb, and on every database created from aDatabaseresource. Thecnpg_metrics_exporterrole keepsCONNECTon all of them, so monitoring continues to work. Thestreaming_replicarole is grantedCONNECTonpostgres. Any other role, such as a managed role, must own the database or be grantedCONNECT, for example with the.spec.permissionsof aDatabase. Existing databases are never changed, so an operator upgrade does not change any privilege. A cluster bootstrapped withrecoveryorpg_basebackupis changed only when the operator creates the application database because the source does not have it. APoolerwith a custom authentication method needsCONNECTonpostgresfor the role that runs itsauth_query. Grant it with SQL after the role exists, or set.spec.bootstrap.initdb.allowPublicConnectToPostgrestotrueto keepCONNECTforPUBLIConpostgres. (#11976) -
automountServiceAccountTokenis disabled on instance Pods: the operator now always setsautomountServiceAccountToken: falseon instance Pods, the major upgradeJob, and theServiceAccountit generates. Clusters now comply by default with admission policies that forbid the automatic mounting of the token. The containers that need access to the Kubernetes API get an explicitkube-api-accessprojected volume. AServiceAccountsupplied throughserviceAccountNameis not changed. Clusters upgraded from a previous release go through a one-time rolling update. (#11115) -
Default
smartShutdownTimeoutis now 0 seconds: the default of.spec.smartShutdownTimeoutchanged from 180 to 0. New clusters skip the smart shutdown phase and request a fast shutdown (still preceded by aCHECKPOINT) as soon as a PostgreSQL Pod is terminated. The smart phase waits for clients to disconnect. With long-lived application and pooler connections it rarely completes, and it delays node drains and rolling updates. Existing clusters keep the value already stored in their spec. To keep the previous behavior, set.spec.smartShutdownTimeoutto180. (#11944) -
The legacy synchronous replication configuration is deprecated: the method based on
.spec.minSyncReplicas,.spec.maxSyncReplicas, and.spec.postgresql.syncReplicaElectionConstraintis deprecated starting from 1.31.0 and will be removed in 1.33.0. The admission webhook now warns when a cluster uses these fields. Migrate to.spec.postgresql.synchronous. For the same reason, theminandmaxvalues of thecnpg_collector_sync_replicasmetric are deprecated and will be removed in 1.33.0. (#11978, #11990) -
Instances are bootstrapped by an init container, not a Job: new primary and replica instances (
initdb, recovery,pg_basebackup, join, and snapshot restore) are now bootstrapped by an init container of the instance Pod. The operator no longer creates a separateJob, with its own Pod, for every new instance, and no longer waits for it to complete. A stuck bootstrap is now reported in theClusterstatus with the phaseCluster is unrecoverable and needs manual intervention. A replica that resumes a stalled bootstrap reports the phaseCreating a new replica, with an event. A Pod restored by a backup tool together with its PVCs does not run the bootstrap again on its data. Tooling that watches the bootstrapJobs must be updated. (#11319, #11549, #11608, #11801) -
Online volume snapshot backups no longer include the WAL volume: an online volume snapshot backup of a cluster with a dedicated WAL volume (
.spec.walStorage) now includes onlyPGDATAand the tablespaces, because the recovery of an online backup needs the WAL archive in any case. The restore of such a backup creates an empty WAL volume and fetches the WAL files from the archive, so the recovery needs asourcethat points to a working WAL archive. Cold backups still include the WAL volume. Existing backups are not affected. (#11734) -
The status port always uses TLS: all instances have used TLS to communicate with the operator since 1.24, so the HTTP fallback has been removed. This affects you only if some Pods were created by an operator older than 1.24. In that unlikely case, run a manual rolling update of those Pods to recreate them with a TLS-enabled status port. Contributed by @GellertBabel. (#11370, #11946)
-
The
observedvalue ofcnpg_collector_sync_replicashas a new meaning: it now counts the standbys attached to the primary in thesyncorquorumstate, and no longer the number requested insynchronous_standby_names. With quorum-based replication every attached candidate is counted, soobservedcan be higher thanexpected. Alerts that compare the two with!=must useobserved < expected. (#11990)
Features
-
PostgreSQL 19 support: added support for PostgreSQL 19. The default operand image for new clusters that don't set an image is now
19.0-system-trixie. Existing clusters keep their current image. (#11936) -
Failover and switchover improvements based on the primary
Lease: failover and switchover are more reliable and easier to follow. The changes build on the primaryLeaseintroduced in 1.30.0.-
Failover:
- Reduced the failover time when a partitioned primary keeps the WAL
receivers waiting: the new primary now counts the
leaseDurationSecondswait from the moment the operator starts the failover, and no longer from the end of the election. (#11798) - Changed the primary isolation check to use the primary
Lease. The time an isolated primary takes to stop now depends on the.spec.primaryLeasetimings, like the time a replica waits before it promotes, and no longer on the liveness probe periods. A primary that cannot renew itsLeasefirst tries a fast shutdown, and uses an immediate shutdown only if the fast one does not complete in time. The remaining WAL can then reach the new primary when only the API server was unreachable. (#11357, #11805) - Added the detection of replicas that diverged from the timeline of
the primary. This can happen when the promoted replica is not the
most advanced one. A diverged replica is excluded from the read
services, the election, and the failover quorum. It is reported in
the new
divergedInstancesstatus field, theReplicasHealthycondition, aReplicaDivergedevent, and thecnpg_collector_replicas_divergedmetric. The operator then fences the instance and drops its replication slot on the primary. The instance stays fenced until its PVC is replaced: rebuild the replica withkubectl cnpg destroy CLUSTER INSTANCE. Replica clusters do not report or fence diverged instances. (#11251) - Avoided a failover when all the Pods of a cluster are deleted at
once. The current primary can start again, and a pending failover
is canceled with a
FailoverCancelledevent. (#11940) - Avoided a cluster without a primary when the operator selects a
different replica to promote before the first one is promoted. The
first replica now stops renewing the primary
Lease, so the new one can take it. (#11677) - Made a primary stop when another instance reports that the primary was replaced, even when the primary isolation check is disabled. (#11795)
- Made the liveness probe fail, so that the kubelet restarts the
container, when the instance manager hangs or when PostgreSQL is
still running
.spec.immediateShutdownTimeoutseconds after an immediate shutdown request. (#11358)
- Reduced the failover time when a partitioned primary keeps the WAL
receivers waiting: the new primary now counts the
-
Switchover:
- Made a switchover wait until the new primary has all the data that
the previous primary published on the
Lease, in thecnpg.io/positionannotation (LSN, timeline, instance state, and Pod). A candidate that is still receiving WAL, for example from the archive, promotes as soon as it has all of it. The instance log and aPromotionHeldBackevent on theClusterreport the status and the available options: wait, remove thecnpg.io/positionannotation from theLeaseto promote without waiting (the replica then promotes without the data that only the previous primary has), or cancel the switchover (see the next item). Failovers, and cases where the position is unknown, are not affected. (#11885, #11932) cnpgplugin: madepromotedetect a switchover in progress, so that it no longer changes it by accident. To return to the previous primary, cancel the switchover withkubectl cnpg promote --force CLUSTER CURRENT-PRIMARY. (#11956)
- Made a switchover wait until the new primary has all the data that
the previous primary published on the
-
-
Export logs via OpenTelemetry without a DaemonSet: the operator, the instance manager, and the PgBouncer instance manager can now send their logs via OTLP (gRPC or HTTP, with TLS and headers) directly to an OpenTelemetry collector. The export is enabled with the standard
OTEL_*environment variables. They are read from the operatorDeployment, from theenvandenvFromof aCluster(so each cluster can use its own collector), and from the Pod template of aPooler. PostgreSQL and PGAudit records are exported as structured attributes. The configured log level applies, and the standard output is unchanged. The export never slows down PostgreSQL: records that the collector cannot receive in time are dropped. The queue is flushed before exiting. (#11783) -
In-place resource resizing of instance Pods: a new
.spec.resourcesUpdateStrategyfield acceptsrecreate(the default) orinPlace. WithinPlace, when only the container resources of a running Pod change, the operator resizes the Pod through thepods/resizesubresource and does not delete it. Nothing restarts, and the primary needs no switchover. The Pod is recreated when the change cannot be applied in place.inPlacerequires Kubernetes 1.33 or later. (#11116) -
Failure domain-aware synchronous replication: added the mutually exclusive
podFailureDomainKeysandnodeFailureDomainKeysoptions to.spec.postgresql.synchronous. They restrict the selection of synchronous standbys to instances in a failure domain (such as an availability zone) different from the one of the primary. An outage of a single zone can then no longer stop the primary and all its synchronous replicas at once. The constraint applies only when it can be fully satisfied. Otherwise the operator uses the regular selection. (#11144) -
Generated passwords for declarative roles: a
DatabaseRolecan now include apasswordstanza, so that the operator generates the password and no existingSecretis required. The password is stored in akubernetes.io/basic-authSecret(named<databaserole-name>-passwordby default), with configurable generation criteria, and withdurationandrenewBeforefor automatic rotation. On aDatabaseRole, thepasswordSecretanddisablePasswordfields still work but are deprecated in favor of thepasswordstanza. A role cannot use both. (#11337) -
Database privileges in the
Databaseresource: a new.spec.permissionsstanza declaratively grants and revokes theCONNECT,CREATE, andTEMPORARYprivileges on a database. You no longer need to run SQL scripts after the database is created. You can also revokeCONNECTfrompublicon an existing database and grant it to specific roles. The operator reads the current privileges, runs aGRANTorREVOKEonly when needed, and reports the outcome in the status. (#11906) -
Schema privileges in the
Databaseresource: schema entries in theDatabaseCRD accept a newpermissionsfield to declaratively grant or revoke theUSAGEandCREATEprivileges on a schema, in addition to the existingownerandensuremanagement. Contributed by @BRGOVIND. (#10910)
Enhancements
-
Added an admission webhook warning when a multi-instance cluster has no synchronous replication configured. It explains the durability trade-off of asynchronous replication. (#11148)
-
Added
.spec.bootstrap.pg_basebackup.additionalArgsto append custom arguments (for example--max-rateor--checkpoint) to thepg_basebackupcommand built by the operator. (#11595) -
Added
.spec.bootstrap.pg_basebackup.tablespaceMappingto clone a source instance whose tablespaces are not in the CloudNativePG location. It maps each tablespace declared in.spec.tablespacesto its source path. (#11649) -
Added optional
durationandrenewBeforefields to theclientCertificatestanza of aDatabaseRole. Each role can now have its own certificate lifetime and renewal window, different from the operator-wideCERTIFICATE_DURATIONandEXPIRING_CHECK_THRESHOLDvalues. (#11342) -
Added a set of editor roles for automation:
cnpg-editor-role, an aggregate role for the namespaced resources, plus theImageCatalog,ClusterImageCatalog, andDatabaseRoleeditor roles. The documentation explains the opt-in aggregation into the built-ineditandadminroles. (#11784) -
Added the
cnpg-viewer-roleClusterRole, with read-only access to the CloudNativePG, Barman Cloud, and Klio API groups, and documented read-only DBA personas with sampleRoleBindings. (#11684)
Security and Supply Chain
-
Signed each architecture-specific manifest of the multi-architecture container images with Cosign, in addition to the multi-architecture index. (#11971)
-
Documented that a user who can write
DatabaseRoleobjects can make the instanceServiceAccountread anySecretof the namespace whose name they know, throughpassword.secret. Give write access toDatabaseRoleonly to users who are allowed to read thoseSecrets. (#12010) -
Hardened the
Poolerconfiguration: newlines andNULbytes in.spec.pgbouncer.authQuery, in theauth_username and in the names of.spec.pgbouncer.parameterscan no longer inject settings intopgbouncer.ini. A parameter name that cannot be a valid setting is now rejected. (#12011)
Fixes
-
Fixed an endless rollout loop, and backups that never started, when an admission webhook rewrites the container images of instance Pods, for example to use a registry mirror. The operator now compares the images it rendered, not the live ones. Contributed by @Vince-Chenal. (#12012)
-
Fixed instances stuck forever with a provisioned PVC and no Pod. This could happen to any instance, not only to the first primary, when the operator was interrupted during the bootstrap. (#11142)
-
Fixed a shutdown that sent a signal to an unrelated process when a leftover
postmaster.pidcontains the PID of a live process that is not PostgreSQL. (#11992) -
Fixed the
minandmaxvalues of thecnpg_collector_sync_replicasmetric, which were reported as 0 for clusters configured through.spec.postgresql.synchronous. (#11979)
Supported versions
- Kubernetes 1.37, 1.36, and 1.35
- PostgreSQL 19, 18, 17, 16, and 15
- PostgreSQL 19.0 (
19.0-system-trixie) is the default image - PostgreSQL 15 support ends on November 11, 2027
- PostgreSQL 19.0 (