CLI Tool to assist with upgrading a Postgres installation running on Kubernetes

brew install containerinfra/cli/kube-pg-upgrade

Download the latest binary on GitHub Releases.

Binaries available for Linux, Windows and MacOS.

Circle 1
Circle 2
Circle 3
Upgrade PostgreSQL in Kubernetes
pg_upgrade automation
PostgreSQL maintenance
PostgreSQL logo

Why kube-pg-upgrade

Avoid Down time and data-loss

Upgrading PostgreSQL in a Kubernetes environment can be a complex and time-consuming process. Manually performing the upgrade involves several steps, including taking backups, shutting down the database, upgrading the software, and migrating the data. This process can be error-prone and may lead to downtime and data loss if not executed correctly..

Reduce Risk

By using an automated tool like kube-pg-upgrade, you can simplify and streamline the upgrade process. It ensures that the upgrade is performed consistently and reduces the risk of human error.

Save time and Effort

By utilizing kube-pg-upgrade, DevOps engineers can save time and effort in managing PostgreSQL upgrades in Kubernetes clusters. The tool simplifies the process, reduces the risk of errors, and ensures a smooth and efficient upgrade experience.

How to use

❯ kube-pg-upgrade upgrade sts -h
    kube-pg-upgrade pgupgrade statefulset  [flags]

    statefulset, sts

# run pg_upgrade for a statefulset pod
kube-pg-upgrade upgrade sts database-postgresql --version=15 --current-version=11

        --current-version string     current version of the postgres database. Optional, will attempt auto discovery if left empty. For example: 9.6, 14, 15, 16, etc..
    -i, --extra-initdb-args string   provide any additional arguments for init-db. Use the same arguments that were provided when the database was originally created. See https://www.postgresql.org/docs/current/pgupgrade.html. Otherwise will attempt to auto detect.
    -h, --help                       help for statefulset
    -n, --namespace string           namespace of the postgres instance. Default is the configured namespace in your kubecontext.
        --size string                New size. Example: 10G
        --source-pvc-name string     The name of the Persistent Volume Claim with the current postgres data. Optional, will attempt auto discovery if left empty.
        --subpath string             subpath used for mounting the pvc
        --target-pvc-name string     Target name of Persistent Volume Claim that will serve as the target for the upgraded postgres data. This is an optional setting, will use the source PVC name by default.
        --timeout duration           The length of time to wait before giving up, zero means infinite
        --upgrade-image string       Container image used to run pg_upgrade. (default "tianon/postgres-upgrade")
    -u, --user string                user used for initdb
    -v, --version string             target postgres major version. For example: 14, 15, 16, etc..


To run kube-pg-upgrade and perform a PostgreSQL upgrade within a Kubernetes namespace:

kube-pg-upgrade postgres upgrade -n db-upgrade-test \
    --version=15 \
    --target-pvc-name=data-test-db-postgresql-primary-0 \


You can view the latest available releases here.