Manage TLS certificates
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.
By default, each MySQL cluster has pre-configured TLS certificates and keys. The Cennso Database extension provides two ways to obtain these certificates:
- Automatic TLS certificates (default) – Cennso Database Operator automatically creates a CertificateOpens in a new tab Custom Resource (managed by cert-managerOpens in a new tab) for every cluster deployed with a DBInstance Custom Resource. These certificates are valid for
90days. - Customised TLS certificates – if you need TLS certificates with a custom validity period, use the DBTLSCertificate Custom Resource. In this case, in your
DBInstanceclaim, you must set the spec.tlsSecretName configuration option to an empty string, or skip this configuration parameter.
Note
If you want to create a custom TLS certificate for the new database, you must install the DBTLSCertificate before the database deployment, and configure your MySQL cluster to use the Kubernetes Secret with TLS certificates generated by it. For more information on how to do it, read the Deploy TLS certificates for the MySQL cluster section.
This document describes how to update the TLS certificates in the already existing MySQL cluster deployment.
Create TLS certificates for existing database
To create the custom TLS certificates for your MySQL cluster, use the DBTLSCertificate Custom Resource. After you install the DBTLSCertificate Custom Resource in your Management Cluster, it triggers the generation of new TLS certificates and keys in your Core Cluster. The newly generated TLS certificates and keys are stored in a Kubernetes Secret. The secret is located in the Kubernetes Namespace specified by the spec.namespace configuration option of the DBTLSCertificate CR. The name of the generated secret is cennso-db-{MYSQL-CLUSTER-TLS-CERTIFICATE}-ssl where the MYSQL-CLUSTER-TLS-CERTIFICATE is the value of the metadata.name from the DBTLSCertificate.
Since the secret with the TLS certificates and keys was successfully created, you should put this secret name in the spec.tlsSecretName of your DBInstance claim and deploy the MySQL cluster using it.
For example, using the following YAML manifest, you can deploy the TLS certificates to the database namespace of the database-cluster Core Cluster:
Use the following command to apply the Custom Resource to your Core Cluster:
This generates TLS certificates and stores them in the database namespace with the name cennso-db-tls-certificates-ssl.
To use these TLS certificates with the already deployed MySQL cluster, update the DBInstance Custom Resource which you used to deploy your MySQL cluster. To do this, open the file with the DBInstance Custom Resource that you used to deploy your MySQL cluster and update or set the spec.tlsSecretName. For example:
After this, apply the updated claim to the Management Cluster, so the MySQL cluster is updated with the new TLS certificates. Use the following command to apply the updated DBInstance Custom Resource on your Management Cluster: