reactive-tech / kubegres

Kubegres is a Kubernetes operator allowing to deploy one or many clusters of PostgreSql instances and manage databases replication, failover and backup.

Home Page:https://www.kubegres.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Upgrade between major versions

samstride opened this issue · comments

commented

Hi,

Thank you for maintaining this repo.

We are using kubegres and are on Postgres v14.9.

Is there any documentation that we can follow to upgrade from say 14.9 to 15.4?

Also, is it possible to upgrade directly from 14.9 to 16.0?

Thanks.

Hi,

Thank you for your message.

Internally we upgrade PostgreSql major versions as follows:

  • we run pg_dump to back up our Postgres database running the old version (e.g. Postgres v14.9). We have one database running for each PostgreSql cluster, but if you have many then run pg_dump for each database.
  • We create a new Postgres cluster with Kubegres in which Postgres 16.0 runs. That way we release a new cluster of PostgrSql primary and replica instances in Kubernetes using Postgres 16.0.
  • In this new Posgres cluster, we connect to the Primary POD, and using the tool psql we create our empty database with CREATE DATABASE command, we create a user with CREATE USER command, and run the permission SQL GRANT queries for that user. And then we test the backup by restoring it in the new cluster of PosgreSql.
  • If it worked, we delete the old PostgreSql cluster and make sure all old PVC and PV are deleted too.

We found the steps above simpler than using pg_upgrade.

Alternatively, you can use pg_upgrade

In the page about pg_upgrade, they provided good examples about how to perform upgrades between major versions.

There is also a dedicated upgrade page published by the PostgreSql team: https://www.postgresql.org/docs/current/upgrading.html

I hope that helps.