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. The topic covers three upgrade scenarios:

Important Upgrade Notes:

  • Customers who are upgrading to 1.8.0, and have existing Postgres 14.X instances, will be upgraded to Postgres 14.4. Review the PostgreSQL 14.4 release notes and the issue with databases using CREATE INDEX CONCURRENTLY or REINDEX CONCURRENTLY. After the 1.8.0 upgrade, fix the indexes in thoese instances, using a client like psql.
    For details on how to access the Postgres instances via psql, see Accessing Postgres with External Clients.
    For details how to fix the index corrupution, see the PostgreSQL 14.4 Released announcement.
  • Customers upgrading to 1.7.0 from 1.6.0 and earlier, who are using "postgres" as a value for pgConfig.dbName, pgConfig.appUser, or pgConfig.username, need to restore to another instance before upgrading. For information on the restore process, see Restore to Another Instance.
  • Customers upgrading from Tanzu Operator 1.5.0 and earlier, need to update their regsecret dockerRegistrySecretName from registry.pivotal.io to the updated registry.tanzu.vmware.com.

Upgrading the Operator using the Tanzu Registry

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.

  1. 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.
    
  2. Use Helm to log in to the Tanzu Network Registry by running:

    helm registry login registry.tanzu.vmware.com \
           --username=<USERNAME> \
           --password=<PASSWORD>
    

    Follow the prompts to enter the email address and password for your Tanzu Network account.

  3. 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.tanzu.vmware.com/tanzu-sql-postgres/postgres-operator-chart:v1.8.0
    helm chart export registry.tanzu.vmware.com/tanzu-sql-postgres/postgres-operator-chart:v1.8.0  --destination=/tmp/
    

    With helm CLI 3.7.1 and later,

    helm pull oci://registry.tanzu.vmware.com/tanzu-sql-postgres/postgres-operator-chart --version v1.8.0 --untar --untardir /tmp
    
  4. Update the existing Postgres instance Custom Resource Definition (CRD) with the new values:

    cd /tmp/postgres-operator/
    
    kubectl apply -f crds/
    
  5. 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.8.0
    
    postgresImage: my-custom-registry/postgres-instance:v1.8.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.

  6. 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.8.0  v1.8.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()'"
    

Upgrading the Operator using the Tanzu Network download

  1. 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.

  2. 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: Prior to Tanzu Operator 1.5.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.

    # 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.8.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.8.0
    
    # specify the name of the docker-registry secret to allow the cluster to authenticate with the container registry for pulling images
    dockerRegistrySecretName: regsecret
    
  3. 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/
    
  4. 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
    
  5. 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.8.0  v1.8.0
    

    Verify the image version matches the new Operator version:

    cat images/postgres-*-tag
    
    v1.8.0
    v1.8.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.8.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.8.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()'"
    

Upgrading the Operator using the Tanzu CLI

  1. Use kubectl context to change to the namespace of your package repository.

  2. Find the package repository name of the VMware Tanzu Data Services package repository:

    tanzu package repository list 
    
    NAME                            REPOSITORY                                                                          TAG       STATUS               DETAILS
    tanzu-data-services-repository  registry.tanzu.vmware.com/packages-for-vmware-tanzu-data-services/tds-packages      1.1.0     Reconcile succeeded
    

    where column NAME represents the name of the package repository.

  3. Update the package repository to reflect the new target version:

    tanzu package repository update <your-package-repository-name> \
        --url <MY-REGISTRY>/<TARGET-REPOSITORY>/tds-packages:<TDS-VERSION> \
    

    where:

    • MY-REGISTRY is your own image registry
    • TARGET-REPOSITORY is your target repository
    • TDS-VERSION is the target version you'll like to upgrade to (e.g. 1.1.0)
    | Updating package repository 'tanzu-data-services-repository'
    - Getting package repository 'tanzu-data-services-repository' 
    / Getting package repository 'tanzu-data-services-repository'
    | Validating provided settings for the package repository
    | Updating package repository resource
    - Waiting for 'PackageRepository' reconciliation for 'tanzu-data-services-repository'
    / 'PackageRepository' resource install status: Reconciling
    
    Updated package repository 'tanzu-data-services-repository' in namespace 'default'
    
  4. Verify you have updated the package repository

    tanzu package repository get tanzu-data-services-repository
    
    - Retrieving repository tanzu-data-services-repository... 
    / Retrieving repository tanzu-data-services-repository...
    NAME:          tanzu-data-services-repository
    VERSION:       2571192
    REPOSITORY:    registry.tanzu.vmware.com/packages-for-vmware-tanzu-data-services/tds-packages
    TAG:           1.1.0
    STATUS:        Reconcile succeeded
    REASON:
    
  5. Select your desired version of the available Postgres Operator version

    tanzu package available list postgres-operator.sql.tanzu.vmware.com 
    
    Retrieving package versions for postgres-operator.sql.tanzu.vmware.com... 
    - Retrieving package versions for postgres-operator.sql.tanzu.vmware.com...
      NAME                                    VERSION  RELEASED-AT
      postgres-operator.sql.tanzu.vmware.com  1.7.3    2022-06-09 00:53:39 -0400 EDT
      postgres-operator.sql.tanzu.vmware.com  1.8.0    2022-07-01 15:03:45 -0400 EDT
    
  6. Update the Postgres Operator package to your desired version:

    tanzu package installed update <PACKAGE-NAME> --package-name postgres-operator.sql.tanzu.vmware.com --version <POSTGRES-OPERATOR-VERSION> -f <YOUR-OVERRIDES-FILE-PATH> 
    

    where:

    • PACKAGE-NAME is the name you choose during installation.
    • POSTGRES-OPERATOR-VERSION is the Operator version you choose in the step above
    • YOUR-OVERRIDES-FILE-PATH is your custom overrides path and file, for example overrides.yaml.
    | Updating installed package 'postgres-operator'
    - Getting package install for 'postgres-operator' 
    / Getting package install for 'postgres-operator'
    / Getting package metadata for 'postgres-operator.sql.tanzu.vmware.com'
    | Updating package install for 'postgres-operator'
    / Waiting for 'PackageInstall' reconciliation for 'postgres-operator'
    / 'PackageInstall' resource install status: Reconciling
    
    Updated installed package 'postgres-operator' in namespace 'default'
    
  7. Verify the Postgres Operator package was updated successfully:

    tanzu package installed get postgres-operator
    
    - Retrieving installation details for postgres-operator... 
    / Retrieving installation details for postgres-operator...
    NAME:                    postgres-operator
    PACKAGE-NAME:            postgres-operator.sql.tanzu.vmware.com
    PACKAGE-VERSION:         1.8.0
    STATUS:                  Reconcile succeeded
    CONDITIONS:              [{ReconcileSucceeded True  }]
    USEFUL-ERROR-MESSAGE:
    
check-circle-line exclamation-circle-line close-line
Scroll to top icon