Charmed MySQL K8s
- By Canonical Data Platform
|8.0/stable||75||20 Apr 2023|
|8.0/candidate||75||20 Apr 2023|
|8.0/beta||75||20 Apr 2023|
|8.0/edge||83||26 May 2023|
juju deploy mysql-k8s --channel 8.0/stable
You will need Juju 2.9 to be able to run this command. Learn how to upgrade to Juju 2.9.
Deploy Kubernetes operators easily with Juju, the Universal Operator Lifecycle Manager. Need a Kubernetes cluster? Install MicroK8s to create a full CNCF-certified Kubernetes system in under 60 seconds.
Scale your Charmed MySQL
This is part of the Charmed MySQL Tutorial. Please refer to this page for more information and the overview of the content.
Adding and Removing units
Charmed MySQL K8s operator uses MySQL InnoDB Cluster for scaling. Being built on MySQL Group Replication, provides features such as automatic membership management, fault tolerance, automatic failover, and so on. An InnoDB Cluster usually runs in a single-primary mode, with one primary instance (read-write) and multiple secondary instances (read-only). The future versions on Charmed MySQL K8s will take advantage of a multi-primary mode, where multiple instances are primaries. Users can even change the topology of the cluster while InnoDB Cluster is online, to ensure the highest possible availability.
! Disclaimer: this tutorial hosts replicas all on the same machine, this should not be done in a production environment. To enable high availability in a production environment, replicas should be hosted on different servers to maintain isolation.
Add cluster members (replicas)
You can add two replicas to your deployed MySQL application by scaling it to three units using:
juju scale-application mysql-k8s 3
You can now watch the scaling process in live using:
juju status --watch 1s. It usually takes several minutes for new cluster members to be added. You’ll know that all three nodes are in sync when
juju status reports
Model Controller Cloud/Region Version SLA Timestamp tutorial overlord microk8s/localhost 2.9.38 unsupported 22:48:57+01:00 App Version Status Scale Charm Channel Rev Address Exposed Message mysql-k8s 8.0.31 active 3 mysql-k8s 8.0/stable 36 10.152.183.234 no Unit Workload Agent Address Ports Message mysql-k8s/0* active idle 10.1.84.74 Unit is ready: Mode: RW mysql-k8s/1 active idle 10.1.84.127 Unit is ready: Mode: RO mysql-k8s/2 active idle 10.1.84.73 Unit is ready: Mode: RO
Remove cluster members (replicas)
Removing a unit from the application, scales the replicas down. Before we scale down the replicas, list all the units with
juju status, here you will see three units
mysql-k8s/2. Each of these units hosts a MySQL replica. To scale the application down to two units, enter:
juju scale-application mysql-k8s 2
You’ll know that the replica was successfully removed when
juju status --watch 1s reports:
Model Controller Cloud/Region Version SLA Timestamp tutorial overlord microk8s/localhost 2.9.38 unsupported 22:48:57+01:00 App Version Status Scale Charm Channel Rev Address Exposed Message mysql-k8s 8.0.31 active 3 mysql-k8s 8.0/stable 36 10.152.183.234 no Unit Workload Agent Address Ports Message mysql-k8s/0* active idle 10.1.84.74 Unit is ready: Mode: RW mysql-k8s/1 active idle 10.1.84.127 Unit is ready: Mode: RO
Note: the maximum number of Charmed MySQL K8s units in a single Juju application is 9. It is a limitation of MySQL Group replication, read more about all limitations here.
Help us improve this documentation
Most of this documentation can be collaboratively discussed and changed on the respective topic in the doc category of the Charmhub forum. See the documentation guidelines if you’d like to contribute.