Deploy Cennso Database
This guide provides description of how to deploy the Cennso Database Operator and Cennso Database Instance to get a ready-to-use MySQL cluster of two instances with async replicationOpens in a new tab.
The deployment consists of two stages described in the next two sections:
After the deployment, you can validate your MySQL cluster, create database users, and start to use your database cluster.
Tip
If any issues occur during component deployment, see the troubleshooting guide.
Deploy Cennso Database Operator
This section shows the example of how to deploy the Cennso Database Operator in the Core Cluster specified by the {CORE-CLUSTER-NAME}. After the deployment, the operator Pod runs in the {OPERATOR-NAMESPACE} Kubernetes Namespace and manages the MySQL clusters that DBInstance resources create in the {NAMESPACE-WITH-DATABASE-INSTANCES} Kubernetes Namespace.
To deploy a Cennso Database Operator described above, execute the following steps:
Prepare the
DBOperatorCustom Resource (CR) to deploy the Cennso Database Operator in your Management cluster. This CR defines the connection to the Core Cluster and the operator configuration. For example:yamlFor more information about available configuration options, see the Cennso Database Operator and Cennso Database Operator Custom Resource Definition documents.
Apply the prepared CR to your Management Cluster:
bashCheck your target cluster for the ready Cennso Database Operator Pod:
bashCheck the state of the
READYcolumn in the output. As soon as all the containers within the Cennso Database Operator Pod are ready, you can move to the deployment of the MySQL cluster.
During an upgrade of the Cennso Database Operator or MySQL instances, the operator waits five minutes, as defined by the spec.replicationSyncWaitTimeOnUpgrade setting, to ensure that the MySQL instances are synchronised.
Deprecated: The spec.replicationSyncWaitTimeOnUpgrade 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.
The optional spec.storage option creates the mysql-cluster-storage storage class with the /opt/local-path-provisioner/mysql-cluster path for the MySQL instances data directoriesOpens in a new tab on the nodes. The DBInstance CR in this guide refers to this storage class by name. To deploy more MySQL clusters with separate storage, add more entries to spec.storage.classes. You can omit spec.storage when the MySQL cluster uses a storage class that already exists on the Core Cluster, as described in the Storage configuration section of the Cennso Database Operator document.
Deploy TLS certificates for the MySQL cluster
Note
This is an optional step. If you do not need custom TLS certificates for your MySQL cluster, move directly to the Deploy Cennso Database Instance section.
By default, each MySQL cluster has the TLS certificates requested from the cert-managerOpens in a new tab. These certificates are valid for 90 days. To customise the validity time of the TLS certificates for your MySQL cluster, you can use the DBTLSCertificate CR. For example:
This Custom Resource produces a Kubernetes Secret cennso-db-{MYSQL-CLUSTER-TLS-CERTIFICATE}-ssl in the {NAMESPACE-WITH-DATABASE-CLUSTER} namespace. After the Kubernetes Secret with TLS certificate and keys is created, you can set the following configuration options in the DBInstance Custom Resource to configure your MySQL cluster to use these TLS certificates and keys:
If you need to update TLS certificates for the already existing deployment of the MySQL cluster, read the Manage TLS certificates document.
Important
Any update or renewal of the TLS certificates leads to the graceful restart of the MySQL database cluster, starting from the secondary instances and ending with the primary.
Deploy Cennso Database Instance
After you have deployed the Cennso Database Operator, you can deploy a MySQL cluster using the DBInstance CR.
This section shows the example of how to deploy the MySQL cluster in the Core Cluster specified by the {CORE_CLUSTER_NAME}. After the deployment, the MySQL cluster pods run in the Kubernetes Namespace specified in the {DATABASE-CLUSTER-NAMESPACE}. The MySQL cluster uses default TLS certificates and keys generated by the cert-managerOpens in a new tab, which are valid for 90 days. If you need custom validity of the TLS certificates and keys, read Deploy TLS certificates for the MySQL cluster and Manage TLS certificates documents.
Note
The deployment described in this example does not contain information about:
- MySQL exporter which collects metrics from the MySQL instance(s)
binary-donorwhich helps to maintain the MySQL instances in sync after restart
To learn how to enable and configure observability for the MySQL cluster and binary-donor, read the Enable metrics collector and Enable binary-donor documents.
To deploy a Cennso Database Instance described above, execute the following steps:
Ensure you have the Cennso Database Operator deployed in your cluster, and the Kubernetes Namespace you want to use for the MySQL cluster deployment is mentioned in the spec.watchNamespaces field of the Cennso Database Operator CR.
Prepare the storage for the MySQL instances. The preparation depends on the source of the MySQL instance volumes, as described in the Storage configuration section of the Cennso Database Instance document:
-
Node-local volumes (used in this guide). Create the directories for the MySQL instances on the nodes where you plan to deploy them. You can use the following commands to create the directories on your nodes:
bash -
Volumes provided by the storage class. If the storage class already exists on the Core Cluster, no preparation is needed. If the storage class is created by the Cennso Database Operator, ensure the local-path-provisionerOpens in a new tab on your Core Cluster is configured to use the path of the storage class on the nodes where the MySQL instances can run. To do this, check the
local-path-configConfigMap and add the path for these nodes if it is missing. You can do this using the following command:bashThe output should be similar to the following, where you can see the path of the storage class for the nodes:
yaml
-
Prepare the
DBInstanceCustom Resource (CR) to deploy the Cennso Database Instance in your Management Cluster. This CR defines the connection to the Core Cluster, the storage configuration, and the settings of the MySQL instances. For example:yamlThis example uses node-local volumes. To use volumes provided by the storage class instead, set spec.storage.className to the name of the storage class and list the MySQL instances in spec.instances as empty entries:
yamlImportant
The
DBInstancemetadata.name must not exceed15characters. Longer names cause the generated resource names to be silently truncated, which breaks the HAProxy Service selector and makes the MySQL cluster unreachable through HAProxy. For more information, see the Naming constraint section.Apply the prepared CR to your Management Cluster:
bashCheck for the ready MySQL cluster pods:
bashCheck the state of the
READYcolumn in the output. As soon as all the containers within all MySQL cluster pods are ready, you can start to use the database.