Upgrade single PostgreSQL instances in Docker or Kubernetes with pgautoupgrade
Since the downfall of Bitnami, I moved all single PostgreSQL instances to the Cloudpirates Helm charts.
Running single instances are fine in many use cases, but if you want to upgrade from a previous major version of PostgreSQL to another one, you
have to perform a full database migration. This could be done using pg_dump or inline via the pg_upgrade command.
To make such upgrades easier, I implemented an OCI image called pgautoupgrade, which contains the older binaries of PostgreSQL 14 up to the recently released PostgreSQL 19 version. It can be used to perform inline upgrades of PostgreSQL instances in a Docker or Kubernetes environment.
For Kubernetes, just configure an initContainer like:
initContainers:
- name: postgres-upgrade
image: ghcr.io/mreiche/pgautoupgrade:14-19.alpine3.24
securityContext:
runAsUser: 70 # Pass your UID here
fsGroup: 70 # Pass your UID here
env:
- name: PGDATA
value: /var/lib/postgresql/pgdata
volumeMounts:
- name: pgdata
mountPath: /var/lib/postgresql
Make sure, that you use the right distribution flavor of Alpine or Debian based images, because they are binary incompatible in some use cases.
For more details and configuration options, follow the documentation of the Github Repository linked above.