Upgrade a database
This document describes how to upgrade Cennso Database Operator and Cennso Database Instance. If you need to update the Cennso Database extension itself, read the Installation document.
You can upgrade both Cennso Database Operator and Cennso Database Instance, or one at a time.
Important
For this moment, Cennso Database does not support the upgrade of the following sub-components:
- Upgrade to a new major version of MySQL - make sure you do not set the spec.mysql.image.tag parameter of the
DBInstancecomposition to a newer major version of the MySQL server during upgrade. - Upgrade to a new version of Operator - make sure you do not set the spec.image and spec.chart parameters of the
DBOperatorcomposition to a newer version of the Operator during upgrade.
The upgrade process of the sub-components mentioned above is impossible because of absence of backward compatibility. If you need to upgrade these sub-components, you should create a new Cennso Database Instance with the desired version and migrate your data.
Before upgrading the database cluster, follow the general recommendations:
-
When upgrading the Cennso Database Instance under load, ensure your Cennso Database Operator has an adequate spec.replicationSyncWaitTimeOnUpgrade value configured. It is recommended to check the replication lag before the upgrade procedure and set the spec.replicationSyncWaitTimeOnUpgrade to not less than
5.Important
Deprecated: This configuration option will be removed in the next release of the Cennso Database extension. Use spec.binaryDonor of the
DBInstanceCustom Resource instead. For more information, see Enablebinary-donor. -
To improve the performance of the upgrade process, you can set the spec.mysql.cloneRequiredOnAsyncCluster to
false. This will skip the cloning process during the upgrade.
Select the extension version
The Cennso Database extension package ships a Composition for every Custom Resource it provides, such as DBOperator and DBInstance. Crossplane keeps the history of each Composition as composition revisions. Installing a new version of the package updates the Compositions and, as a result, creates a new composition revision for each of them, labelled with cennso.com/version of that package. Installing a new package version does not change existing databases: each DBOperator and DBInstance Custom Resource stays on the revision it was created with until you move it. A Custom Resource created without spec.compositionRevisionSelector is pinned in the same way to the revision that was the newest at the time of its creation.
A Custom Resource chooses its revision with spec.compositionRevisionSelector. The revision in use is recorded in spec.compositionRevisionRef of the underlying composite resource. Whether a later change of the selector takes effect depends on the value of the spec.compositionUpdatePolicy parameter:
Manual(default) - the selector is evaluated only once, when the Custom Resource is created. A later change of the label is accepted without an error but has no effect. To move the Custom Resource to another revision, set spec.compositionRevisionRef.name explicitly.Automatic- the selector is evaluated on every reconciliation, and the Custom Resource follows the newest revision that matches the label. Changing the label is enough to move it. Without a selector, anAutomaticCustom Resource follows the newest revision after every package installation.
The Manual default protects production databases from unintended changes. With Automatic, make sure every package version carries a unique cennso.com/version label. Otherwise, rebuilding a package with the reused version label changes the Custom Resource without any changes on your side.
To list the installed composition revisions of the MySQL Custom Resources together with their versions, use the following command on the Management Cluster. The MySQL composite resource kinds start with XDB, which grep uses to exclude other resources:
Upgrade Cennso Database Operator
You can upgrade the Cennso Database Operator using either the Cennso Management Console (CMC) or the CLI:
To update the Cennso Database Operator using CMC:
- Go to Cennso Management → All resources and choose the
DBOperatortile. - Choose the
DBOperatoryou want to upgrade. - Press the
Editbutton. - Go to the Specification tab and edit parameters you want to update.
- If you want to use a different version of the Cennso Database extension, open the Metadata tab and adjust the extension version using the Version field in the Composition section. The Version field sets spec.compositionRevisionSelector, which has no effect on an existing
DBOperatorbecause spec.compositionUpdatePolicy isManualby default. Open the Manifest tab and either set spec.compositionRevisionRef.name to the revision of the new version, or set spec.compositionUpdatePolicy toAutomatic, as described in the Select the extension version section. - After you've edited all the parameters for the upgrade, press the
Updatebutton. - Open the
DBOperatoragain and check spec.compositionRevisionRef.name in the Manifest tab. It must show the revision of the new version. The database operator Deployment is restarted in the Core Cluster only when the new revision renders it differently.
To update the Cennso Database Operator using CLI:
Open the manifest with the
DBOperatorCustom Resource which you used to deploy the Cennso Database Operator.Edit the parameters you want to change for the Cennso Database Operator upgrade.
If you want to use a different version of the Cennso Database extension, update the spec.compositionRevisionSelector.matchLabels in the manifest. This parameter should contain the
cennso.com/versionlabel with the version associated with the Cennso Database extension.To find the available composition revisions and their versions, use the following command:
bashTo update the composition revision associated with the Cennso Database extension, set the
cennso.com/versionlabel:yamlOn an existing
DBOperator, the new label does not take effect because spec.compositionUpdatePolicy isManualby default. If you did not change the default value, choose one of the following ways to move theDBOperatorto the new revision, as described in the Select the extension version section:-
Set the revision explicitly. Take the revision name for the new version from the output of the command above:
yaml -
Set spec.compositionUpdatePolicy to
Automaticto let the selector determine when to update the composition revision:yaml
-
After you've edited all the parameters, save the manifest and apply it to the Management Cluster using the following command:
bashVerify that the composite resource behind the
DBOperatoris on the expected revision and is ready:bashThe REVISION column must show the name of the revision labelled with the new version. If it still shows the previous revision, the version label was changed without one of the options from step 3.
A new revision only changes what differs from the previous one. The database operator Deployment is restarted in the Core Cluster only when the new revision renders it differently, so an unchanged Deployment after a successful switch is expected.
In emergency cases, when you need to upgrade as soon as possible, you can edit the live Custom Resource manifest currently deployed in your Management Cluster. To do this, execute the following steps:
Important
Changes made using kubectl edit are not preserved during redeployment or upgrade of the database operator. Make sure to reflect any modifications in your Custom Resource Definition.
Find the
DBOperatoryou want to update in the Kubernetes namespace specified byNAMESPACEon the Management Cluster. You can list allDBOperatorresources using the following command:bashOpen the
DBOperatormanifest of the Cennso Database Operator you want to update using the following command:bashSave the manifest and close the editor to apply the updated Custom Resource to your Management Cluster.
Upgrade Cennso Database Instance
You can upgrade the Cennso Database Instance using either the Cennso Management Console (CMC) or the CLI:
To update the Cennso Database Instance using CMC:
- Go to Cennso Management → All resources and choose the
DBInstancetile. - Choose the
DBInstanceyou want to upgrade. - Press the
Editbutton. - Go to the Specification tab and edit parameters you want to update.
- If you want to use a different version of the Cennso Database extension, open the Metadata tab and adjust the extension version using the Version field in the Composition section. The Version field sets spec.compositionRevisionSelector, which has no effect on an existing
DBInstancebecause spec.compositionUpdatePolicy isManualby default. Open the Manifest tab and either set spec.compositionRevisionRef.name to the revision of the new version, or set spec.compositionUpdatePolicy toAutomatic, as described in the Select the extension version section. - After you've edited all the parameters for the upgrade, press the
Updatebutton. - Open the
DBInstanceagain and check spec.compositionRevisionRef.name in the Manifest tab. It must show the revision of the new version. TheDBInstancestays not ready while the composed resources with changed renderings are updated in the Core Cluster. This update may restart the related pods. TheDBInstancebecomes ready again when the upgrade is complete.
Important
MySQL instance can take a long time to get up and running after a restart. Before upgrading the database, make sure that the startup probes are configured with a failureThreshold value high enough for the MySQL restore procedure. For more information, see the Cennso Database Instance document.
To update the Cennso Database Instance using CLI:
Open the manifest with the
DBInstanceCustom Resource which you used to deploy the Cennso Database Instance.Edit the parameters you want to change for the Cennso Database Instance upgrade.
If you want to use a different version of the Cennso Database extension, update the spec.compositionRevisionSelector.matchLabels in the manifest. This parameter should contain the
cennso.com/versionlabel with the version associated with the Cennso Database extension.To find the available composition revisions and their versions, use the following command:
bashTo update the composition revision associated with the Cennso Database extension, set the
cennso.com/versionlabel:yamlOn an existing
DBInstance, the new label does not take effect because spec.compositionUpdatePolicy isManualby default. If you did not change the default value, choose one of the following ways to move theDBInstanceto the new revision, as described in the Select the extension version section:-
Set the revision explicitly. Take the revision name for the new version from the output of the command above:
yaml -
Set spec.compositionUpdatePolicy to
Automaticto let the selector determine when to update the composition revision:yaml
-
After you've edited all the parameters, save the manifest and apply it to the Management Cluster using the following command:
bashVerify that the composite resource behind the
DBInstanceis on the expected revision:bashThe REVISION column must show the name of the revision labelled with the new version. If it still shows the previous revision, the version label was changed without one of the options from step 3.
Wait for the upgrade to finish. After the switch, the composed resources whose rendering changed in the new revision are updated in the Core Cluster. Depending on the change, this restarts the related pods, such as the MySQL exporters, the
binary-donorDeployments, or the MySQL instances themselves. The composite resource reportsREADYasFalseuntil its composed resources are updated and all become ready again. It then reportsREADYasTrue.While the MySQL instances are being restarted, watch the state of the MySQL cluster in the Core Cluster:
bashThe upgrade is complete when the composite resource is
READYand the STATE column of the MySQL cluster showsready.
In emergency cases, when you need to upgrade as soon as possible, you can edit the live Custom Resource manifest currently deployed in your Management Cluster. To do this, execute the following steps:
Important
Changes made using kubectl edit are not preserved during redeployment or upgrade of the MySQL cluster. Make sure to reflect any modifications in your Custom Resource Definition.
Find the
DBInstanceyou want to update in the Kubernetes namespace specified byNAMESPACEon the Management Cluster. You can list allDBInstanceresources using the following command:bashOpen the
DBInstancemanifest of the Cennso Database Instance you want to update using the following command:bashSave the manifest and close the editor to apply the updated Custom Resource to your Management Cluster.
Roll back an upgrade
A rollback to the previous version of the Cennso Database extension uses the same mechanism as the upgrade. The composition revisions of the previous package version stay available on the Management Cluster after a newer version is installed, so you do not need to reinstall the previous package.
To roll back a DBOperator or DBInstance, point it at the previous revision in the same way you moved it forward. If spec.compositionUpdatePolicy is set to Automatic, you can only set the previous version in the cennso.com/version label of the selector. Otherwise, you should set spec.compositionRevisionRef.name to the previous revision name.
Then, apply the manifest and verify the revision as described in the upgrade steps above.