PGUpgrade custom resource, which runs pg_upgrade to migrate data from one major version to the next.
Minor version updates
PostgreSQL releases minor versions frequently to deliver bug fixes and security patches. To apply a minor update, change theimage field in your PostgresCluster spec to reference the newer image tag.
Using the RELATED_IMAGE_POSTGRES environment variable
Whenimage is omitted from the spec, the operator uses an environment variable to look up the image. For a standard PostgreSQL 16 cluster, it reads RELATED_IMAGE_POSTGRES_16. You can update the image by changing this variable in the operator deployment instead of modifying individual cluster specs.
Major version upgrades
A major PostgreSQL upgrade—for example, from PostgreSQL 15 to 16—requires migrating the on-disk data format. PGO uses thePGUpgrade custom resource to orchestrate this process via the pg_upgrade tool.
Step-by-step major upgrade
1
Shut down the PostgresCluster
Set Confirm all pods have terminated:
spec.shutdown: true on your cluster to stop all workloads. Volumes and Services remain in place.2
Create the PGUpgrade resource
Create a Apply it:PGO creates a pod that runs
PGUpgrade manifest that references your cluster by name and specifies the source and target versions.pg_upgrade against the cluster’s data directory.3
Monitor upgrade progress
Watch the The upgrade is complete when the
PGUpgrade status conditions to track progress:Succeeded condition is true.4
Update the PostgresCluster spec
After the upgrade job completes, update your cluster spec to reflect the new major version and the corresponding image. Set Apply the change:
shutdown: false to restart the cluster.5
Verify the upgraded cluster
Confirm PostgreSQL is running on the new version:
PGUpgrade spec reference
The fullPGUpgradeSpec fields are:
PGUpgradeCPUConcurrency is a beta feature gate (enabled by default) that automatically adjusts the jobs parallelism based on available CPU resources on the upgrade pod. See Feature Gates.Next steps
Resize cluster resources
Scale storage and compute after upgrading your cluster.
PGUpgrade reference
Full API reference for the PGUpgrade custom resource.