This topic provides steps to upgrade the Tanzu Postgres Operator and Tanzu Postgres instances to a newer version. Upgrading the Postgres Operator also upgrades the existing Postgres instances.
Warning: The Postgres Operator 1.5.0 release upgrades the Postgres instances to Postgres 11.13. The Postgres instances will restart as a result of the upgrade operation.
The topic covers two upgrade scenarios:
Ensure you have access to Tanzu Network and Tanzu Network Registry. You can use the same credentials for both sites.
Note: Helm CLI 3.7.0 is not supported. Please use 3.7.1 and later.
Set the environment variable to enable Open Container Initiative (OCI) support in the Helm v3 client by running:
export HELM_EXPERIMENTAL_OCI=1
If you skip this step, the following error message might appear:
Error: this feature has been marked as experimental and is not enabled by default.
Use Helm to log in to the Tanzu Network Registry by running:
helm registry login registry.pivotal.io \
--username=<USERNAME> \
--password=<PASSWORD>
Follow the prompts to enter the email address and password for your Tanzu Network account.
Download the Helm chart from the Tanzu Distribution Registry into a local /tmp/ directory:
With helm CLI 3.6 and earlier,
helm chart pull registry.pivotal.io/tanzu-sql-postgres/postgres-operator-chart:v1.5.0
helm chart export registry.pivotal.io/tanzu-sql-postgres/postgres-operator-chart:v1.5.0 --destination=/tmp/
With helm CLI 3.7.1 and later,
helm pull oci://registry.pivotal.io/tanzu-sql-postgres/postgres-operator-chart --version v1.5.0 --untar --untardir /tmp
Update the existing Postgres instance Custom Resource Definition (CRD) with the new values:
cd /tmp/postgres-operator/
kubectl apply -f crds/
If you do not have an existing overrides yaml file, perform the Helm upgrade using:
helm upgrade postgres-operator /tmp/postgres-operator/ --wait
The output is similar to:
Release "postgres-operator" has been upgraded. Happy Helming!
NAME: postgres-operator
LAST DEPLOYED: Fri Jan 7 15:31:43 2022
NAMESPACE: default
STATUS: deployed
REVISION: 4
TEST SUITE: None
where REVISION is a counter for the number of Operator you have performed. If you have upgraded from 1.0 to 1.1, and from 1.1 to 1.2, the REVISION number would be 3.
If you have an existing overrides file, and you are upgrading from a Tanzu Operator before 1.4.0, you must make updates to the structure of the overrides file.
Before Tanzu Operator 1.4.0, operatorImageRepository and operatorImageTag were separate keys used to describe the operator image. Similarly, postgresImageRepository and postgresImageTag were separate keys used to describe the postgres image. Now the values are combined into new keys named operatorImage and postgresImage respectively.
For example, if the overrides file contained:
---
operatorImageRepository: my-custom-registry/postgres-operator
operatorImageTag: v1.3.0
postgresImageRepository: my-custom-registry/postgres-instance
postgresImageTag: v1.3.0
then the new overrides file would look like:
---
operatorImage: my-custom-registry/postgres-operator:v1.5.0
postgresImage: my-custom-registry/postgres-instance:v1.5.0
Then, upgrade using:
helm upgrade postgres-operator /tmp/postgres-operator/ -f /<path-to-your-file>/operator_overrides_values.yaml --wait
where you substitute operator_overrides_values.yaml with your custom name and file location.
Wait for the Operator, Monitor, and Postgres instances to restart. Verify the new Postgres Operator version. The Postgres Operator is updated across all namespaces, including the default.
helm ls
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
postgres-operator default 4 2022-01-06 13:28:05.704226 -0500 CDT deployed postgres-operator-v1.5.0 v1.5.0
To verify the new Postgres instance version, use a command similar to:
kubectl exec -i pod/postgres-sample-0 -- bash -c "psql -c 'select version()'"
Download the latest VMware Tanzu Postgres version from VMware Tanzu Network. Load the new Postgres Operator and Postgres instances images into your container registry following the steps in Setup the Tanzu Operator via a Downloaded Archive File.
Create an operator-overrides.yaml file at a location of your choice or update an existing overrides file. Enter the parameters below replacing operatorImage, postgresImage, and dockerRegistrySecretName with your values:
Note: Previously, `operatorImageRepository` and `operatorImageTag` were separate keys used to describe the operator image. Similarly, `postgresImageRepository` and `postgresImageTag` were separate keys used to describe the postgres image. Now the values are combined into new keys named `operatorImage` and `postgresImage` respectively.
# specify the url for the docker image for the Operator, e.g. gcr.io/<my_project>/postgres-operator
operatorImage: gcr.io/data-pcf-db/postgres-operator:v1.5.0
# specify the docker image for postgres instance, e.g. gcr.io/<my_project>/postgres-instance
postgresImage: gcr.io/data-pcf-db/postgres-instance:v1.5.0
# specify the name of the docker-registry secret to allow the cluster to authenticate with the container registry for pulling images
dockerRegistrySecretName: regsecret
Update the Postgres instance Custom Resource Definition (CRD) with the new values:
cd <your-download-location>/postgres-for-kubernetes-<postgres-version>/
kubectl apply -f operator/crds/
Upgrade the Postgres Operator and instances with the helm upgrade command, specifying your location of the operator-overrides.yaml file:
helm upgrade -f ./operator-overrides.yaml postgres-operator operator/
The output is similar to:
Release "postgres-operator" has been upgraded. Happy Helming!
NAME: postgres-operator
LAST DEPLOYED: Mon Nov 22 15:31:43 2021
NAMESPACE: default
STATUS: deployed
REVISION: 4
TEST SUITE: None
Verify the new Postgres Operator version. The Postgres Operator is updated across all namespaces, including the default.
helm ls
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
postgres-operator default 4 2021-02-16 13:28:05.704226 -0500 CDT deployed postgres-operator-v1.5.0 v1.5.0
Verify the image version matches the new Operator version:
cat images/postgres-*-tag
v1.5.0
v1.5.0
Confirm that the images version has also been upgraded:
kubectl describe statefulset.apps/<your-database-name> | grep Image | uniq
Image: gcr.io/data-pcf-db/postgres-instance:v1.5.0
If you have a High Availability configuration, verify the upgrade using:
kubectl describe statefulset.apps/<your-ha-database> | grep Image | uniq
Image: gcr.io/data-pcf-db/postgres-instance:v1.5.0
To verify the new Postgres instance version, use a command similar to:
kubectl exec -i pod/postgres-sample-0 -- bash -c "psql -c 'select version()'"