Upgrade Database and Operator on OpenShift¶
Upgrading database and Operator on Red Hat Marketplace or to upgrade Red Hat certified Operators on OpenShift generally follows the standard upgrade scenario, but includes a number of special steps specific for these platforms.
Upgrading the Operator and CRD¶
-
First of all you need to manually update
initImage
Custom Resource option with the value of an alternative initial Operator installation image. You need doing this for all database clusters managed by the Operator. Without this step the cluster will go into error state after the Operator upgrade.-
Find the initial Operator installation image with
kubectl get deploy
command:$ kubectl get deploy percona-server-mongodb-operator -o yaml
Expected output
... "containerImage": "registry.connect.redhat.com/percona/percona-server-mongodb-operator@sha256:201092cf97c9ceaaaf3b60dd1b24c7c5228d35aab2674345893f4cd4d9bb0e2e", ...
-
Apply a patch to update the
initImage
option of your cluster Custom Resource with this value taken fromcontainerImage
. Supposing that your cluster name ismy-cluster-name
, the command should look as follows:$ kubectl patch psmdb my-cluster-name --type=merge --patch '{ "spec": { "initImage":"registry.connect.redhat.com/percona/percona-server-mongodb-operator@sha256:201092cf97c9ceaaaf3b60dd1b24c7c5228d35aab2674345893f4cd4d9bb0e2e" }}'
-
-
Now you can actually update the Operator via the Operator Lifecycle Manager (OLM) web interface.
Login to your OLM installation and list installed Operators for your Namespace to see if there are upgradable items:
Click the “Upgrade available” link to see upgrade details, then click “Preview InstallPlan” button, and finally “Approve” to upgrade the Operator.
Upgrading Percona Server for MongoDB¶
-
Make sure that
spec.updateStrategy
option in the Custom Resource is set toSmartUpdate
,spec.upgradeOptions.apply
option is set toNever
orDisabled
(this means that the Operator will not carry on upgrades automatically).... spec: updateStrategy: SmartUpdate upgradeOptions: apply: Disabled ...
-
Find the new initial Operator installation image name (it had changed during the Operator upgrade) and other image names for the components of your cluster with the
kubectl get deploy
command:$ kubectl get deploy percona-server-mongodb-operator -o yaml
Expected output
... "image": "registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:5d29132a60b89e660ab738d463bcc0707a17be73dc955aa8da9e50bed4d9ad3e", ... "initImage": "registry.connect.redhat.com/percona/percona-server-mongodb-operator@sha256:8adc57e9445cfcea1ae02798a8f9d6a4958ac89f0620b9c6fa6cf969545dd23f", ... "pmm": { "enabled": true, "image": "registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:165f97cdae2b6def546b0df7f50d88d83c150578bdb9c992953ed866615016f1", ... "backup": { "enabled": true, "image": "registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:a73889d61e996bc4fbc6b256a1284b60232565e128a64e4f94b2c424966772eb", ...
-
Apply a patch to set the necessary
crVersion
value (equal to the Operator version) and update images in your cluster Custom Resource. Supposing that your cluster name iscluster1
, the command should look as follows:$ kubectl patch psmdb my-cluster-name --type=merge --patch '{ "spec": { "crVersion":"1.19.1", "image": "registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:5d29132a60b89e660ab738d463bcc0707a17be73dc955aa8da9e50bed4d9ad3e", "initImage": "registry.connect.redhat.com/percona/percona-server-mongodb-operator@sha256:8adc57e9445cfcea1ae02798a8f9d6a4958ac89f0620b9c6fa6cf969545dd23f", "pmm": {"image": "registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:165f97cdae2b6def546b0df7f50d88d83c150578bdb9c992953ed866615016f1"}, "backup": {"image": "registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:a73889d61e996bc4fbc6b256a1284b60232565e128a64e4f94b2c424966772eb"} }}'
Warning
The above command upgrades various components of the cluster including PMM Client. If you didn’t follow the official recommendation to upgrade PMM Server before upgrading PMM Client, you can avoid PMM Client upgrade by removing it from the list of images as follows:
$ kubectl patch psmdb my-cluster-name --type=merge --patch '{ "spec": { "crVersion":"1.19.1", "image": "registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:5d29132a60b89e660ab738d463bcc0707a17be73dc955aa8da9e50bed4d9ad3e", "initImage": "registry.connect.redhat.com/percona/percona-server-mongodb-operator@sha256:8adc57e9445cfcea1ae02798a8f9d6a4958ac89f0620b9c6fa6cf969545dd23f", "backup": {"image": "registry.connect.redhat.com/percona/percona-server-mongodb-operator-containers@sha256:a73889d61e996bc4fbc6b256a1284b60232565e128a64e4f94b2c424966772eb"} }}'
-
The deployment rollout will be automatically triggered by the applied patch.