Setting up a HA mysql/maraidb DB
Setting up a HA maraidb DB (“mysql”) is easy with bitnami helm charts. Such a HA cluster is made possibly by the galera add-on for maraidb. Galera even creates multi master clusters that coordinate read as well as write operations.
Bitnami charts can be enabled globally usign “Manage Catalogs” in rancher and then are availabel as “Apps”. Use “Add Catalog” and use https://charts.bitnami.com/bitnami. This URL serves “Helm v3” charts (“Helm v2” is EOL now).
We want to run mariadb as a shared service used by multiple projects and namespaces. So it is best to run it in a dedicated project “shared DBs” in a namespace “shared-dbs”.
For applications such as this which do their own HA management for their storage needs we created the “local-hdd” storage class using the local-storage-provisioner and assigned partitions on SSD or HDD local to the storage nodes.
We will use 5Gi or a bit more for each mariadb node.
The database will be available inside the cluster using the cluster DNS as mariadb.shared-dbs.
We will also expose the service to the outside of the cluster using just the mraidb/mysql default port 3306. Because we run one service on each node an exposed “NodePort” 3306 will do here.
By default “NodePorts” are limited to 30000-32767“. As the compute nodes don't run anything important on the ports 3000 and up we can change this setting which is exposed in te rancher UI. We can “Edit” the cluster and set this value in “Advanced Options”.
After changing this the cluster will update. This takes a while.
So we “Launch” a new up, search for “mariadb” and select “maraidb-galera” (“mariadb-cluster” has a big “DEPRECATED” warning and so should not be used anymore)
We probably want to change the name to just maraidb(I don't think galera is an important detail)
Also we want to change the namespace to shared-dbs which is in our shared DBs project
For the defaults of this chart please refer to the very nice documentation you can view directly in rancher when you configure the app for launching in “Detailed Descriptions”. One default that is quite right for us is a replicaCountof 3. Passwords will be randomly genereated and can be viewed under “Secrets”.
We customize the chart with the values below:
image.tag=10.2 rbac.create=true persistence.storageClass=local-hdd persistence.size=5Gi podLabels=ID: "99999" fullnameOverride=mariadb service.type=NodePort service.nodePort=3306
- If not set the
image.tagor the version of the DB used will be set to rolling master. The documentation for the chart explicitly says to not use this for production. We try the oldest supported version of this chart for now. - We use
rbacin our cluster so this should be true. - We set the persistence for our mariadb as described above
- Bitname charts tend to use very long names for the services so they are not easyly colliding. As the shared (and first) instance we don't need to worry about this so force a short name
- Exposing the DB on any node it runs on (so all in our setup) the custom default port is the last customization.