Upgrading EDB Postgres from Version 4.7 to Version 5.0

An instance administrator can upgrade EDB Postgres from Cloud Pak for Data Version 4.7 to Version 5.0.

Who needs to complete this task?

Instance administrator To upgrade EDB Postgres, you must be an instance administrator. An instance administrator has permission to manage software in the following projects:

The operators project for the instance

The operators for this instance of EDB Postgres are installed in the operators project. In the upgrade commands, the ${PROJECT_CPD_INST_OPERATORS} environment variable refers to the operators project.

The operands project for the instance

The custom resources for the control plane and EDB Postgres are installed in the operands project. In the upgrade commands, the ${PROJECT_CPD_INST_OPERANDS} environment variable refers to the operands project.

When do you need to complete this task?

Review the following options to determine whether you need to complete this task:

  • If you want to upgrade the control plane and one or more services at the same time, follow the process in Upgrading an instance of Cloud Pak for Data instead.
  • If you didn't upgrade EDB Postgres when you upgraded the control plane, complete this task to upgrade EDB Postgres.

    Repeat as needed If you are responsible for multiple instances of Cloud Pak for Data, you can repeat this task to upgrade more instances of EDB Postgres on the cluster.

Information you need to complete this task

Review the following information before you upgrade EDB Postgres:

Version requirements

All the components that are associated with an instance of Cloud Pak for Data must be installed at the same release. For example, if the Cloud Pak for Data control plane is at Version 5.0.3, you must upgrade EDB Postgres to Version 5.0.3.

Environment variables
The commands in this task use environment variables so that you can run the commands exactly as written.
  • If you don't have the script that defines the environment variables, see Setting up installation environment variables.
  • To use the environment variables from the script, you must source the environment variables before you run the commands in this task. For example, run:
    source ./cpd_vars.sh
Storage requirements
You don't need to specify storage when you upgrade EDB Postgres.

Before you begin

This task assumes that the following prerequisites are met:

Prerequisite Where to find more information
The cluster meets the minimum requirements for EDB Postgres. If this task is not complete, see System requirements.
The workstation from which you will run the upgrade is set up as a client workstation and has the following command-line interfaces:
  • Cloud Pak for Data CLI: cpd-cli
  • OpenShift® CLI: oc
If this task is not complete, see Updating client workstations.
The Cloud Pak for Data control plane is upgraded. If this task is not complete, see Upgrading an instance of Cloud Pak for Data.
For environments that use a private container registry, such as air-gapped environments, the EDB Postgres software images are mirrored to the private container registry. If this task is not complete, see Mirroring images to a private container registry.
For environments that use a private container registry, such as air-gapped environments, the cpd-cli is configured to pull the olm-utils-v3 image from the private container registry. If this task is not complete, see Pulling the olm-utils-v2 image from the private container registry.

Procedure

Complete the following tasks to upgrade EDB Postgres:

  1. Preparing to upgrade service instances to a newer version of PostgreSQL
  2. Upgrading the service
  3. Validating the upgrade
  4. Upgrading existing service instances
  5. What to do next

Preparing to upgrade service instances to a newer version of PostgreSQL

Before you upgrade EDB Postgres, ensure that the PostgreSQL clusters associated with the service are configured to pickup any new features that are available in newer versions of PostgreSQL.

  1. Get the list of EDB Postgres service instances:
    oc get CPDEdbInstance \
    --namespace=${PROJECT_CPD_INST_OPERANDS}
  2. Get the list of PostgreSQL clusters:
    oc get clusters.postgresql.k8s.enterprisedb.io \
    -n ${PROJECT_CPD_INST_OPERATORS}
  3. For each service instance returned by the oc get CPDEdbInstance command, identify the corresponding PostgreSQL clusters.
    For example, if you have two EDB Postgres service instances named:
    • na-sales
    • ap-sales
    The corresponding PostgreSQL clusters would be named:
    • na-sales-edb-db
    • ap-sales-edb-db
  4. For each PostgreSQL cluster associated with an EDB Postgres service instance:
    1. Set the CLUSTER_NAME environment variable to the name of a PostgreSQL cluster associated with a service instance
      export CLUSTER_NAME=<cluster-name>
    2. Check the value of the primaryUpdateMethod parameter:
      oc get clusters.postgresql.k8s.enterprisedb.io ${CLUSTER_NAME} \
      -n ${PROJECT_CPD_INST_OPERATORS} \
      -o json | jq -r '.spec.primaryUpdateMethod'
      • If the value is switchover proceed to the next step.
      • If the value is restart, patch the cluster to change primaryUpdateMethod to switchover:
        oc patch cluster.postgresql.k8s.enterprisedb.io ${CLUSTER_NAME}  \
        --namespace ${PROJECT_CPD_INST_OPERATORS} \
        --type=merge \
        --patch '{ "spec": {"primaryUpdateMethod": "switchover"}}'
    3. Check the value of the enableSuperuserAccess parameter:
      oc get clusters.postgresql.k8s.enterprisedb.io ${CLUSTER_NAME} \
      -n ${PROJECT_CPD_INST_OPERATORS} \
      -o json | jq -r '.spec.enableSuperuserAccess'
      • If the value is true proceed to the next step.
      • If the value is false, patch the cluster to change enableSuperuserAccess to true:
        oc patch cluster.postgresql.k8s.enterprisedb.io <cluster-name>  \
        --namespace ${PROJECT_CPD_INST_OPERATORS} \
        --type=merge \
        --patch '{ "spec": {"enableSuperuserAccess": true}}'
    4. Check the value of the logLevel parameter:
      oc get clusters.postgresql.k8s.enterprisedb.io ${CLUSTER_NAME} \
      -n ${PROJECT_CPD_INST_OPERATORS} \
      -o json | jq -r '.spec.logLevel'
      • If the value is info proceed to Upgrading the service.
      • If the value is anything other than info, patch the cluster to change logLevel to info:
        oc patch cluster.postgresql.k8s.enterprisedb.io <cluster-name>  \
        --namespace ${PROJECT_CPD_INST_OPERATORS} \
        --type=merge \
        --patch '{ "spec": {"logLeve": "info"}}'

Upgrading the service

Important: The Operator Lifecycle Manager (OLM) objects for EDB Postgres were updated when you upgraded the Cloud Pak for Data platform. The cpd-cli manage apply-olm updates all of the OLM objects in the operators project at the same time.

To upgrade EDB Postgres:

  1. Log the cpd-cli in to the Red Hat® OpenShift Container Platform cluster:
    ${CPDM_OC_LOGIN}
    Remember: CPDM_OC_LOGIN is an alias for the cpd-cli manage login-to-ocp command.
  2. Update the custom resource for EDB Postgres.
    cpd-cli manage apply-cr \
    --components=edb_cp4d \
    --release=${VERSION} \
    --cpd_instance_ns=${PROJECT_CPD_INST_OPERANDS} \
    --license_acceptance=true \
    --upgrade=true

Validating the upgrade

EDB Postgres is upgraded when the apply-cr command returns:
[SUCCESS]... The apply-cr command ran successfully

If you want to confirm that the custom resource status is Completed, you can run the cpd-cli manage get-cr-status command:

cpd-cli manage get-cr-status \
--cpd_instance_ns=${PROJECT_CPD_INST_OPERANDS} \
--components=edb_cp4d

Upgrading existing service instances

To upgrade the service instances:

  1. Log in to Red Hat OpenShift Container Platform as an instance administrator.
    ${OC_LOGIN}
    Remember: OC_LOGIN is an alias for the oc login command.
  2. Get the list of EDB Postgres service instances:
    oc get CPDEdbInstance \
    --namespace=${PROJECT_CPD_INST_OPERANDS}
  3. Set the INSTANCE_NAME environment variable to the name of the service instance that you want to upgrade:
    export INSTANCE_NAME=<instance-name>
  4. Set the INSTANCE_VERSION environment variable to the version that corresponds to the version of Cloud Pak for Data on your cluster:
    export INSTANCE_VERSION=<version>

    Use the following table to determine the appropriate value:

    Cloud Pak for Data version Add-on version Service instance versions
    (Pick one)
    5.0.3 5.0.3 12.20, 13.16, 14.13, 15.8, 16.4
    5.0.2 5.0.2 12.19, 13.15, 14.12, 15.7, 16.3
    5.0.1 1.0.0.0 12.19, 13.15, 14.12, 15.7, 16.3
    5.0.0 1.0.0.0 12.18, 13.14, 14.11, 15.6, 16.2
  5. Update the version in the service instance custom resource:
    oc patch CPDEdbInstance ${INSTANCE_NAME} \
    --namespace=${PROJECT_CPD_INST_OPERANDS} \
    --type=merge \
    --patch="{\"spec\": {\"version\": \"${INSTANCE_VERSION}\"}}"
  6. Repeat the preceding steps to upgrade each service instance in the operands project.

What to do next

Your existing EDB Postgres database instances are ready to use. See Post-installation setup for the EDB Postgres service for more information.