MariaDB
MariaDB Server is another popular open source relational databases. It’s a fork of MySQL from the original developers and is guaranteed to stay open source.
The current Bitnami Helm chart does not allow for a creation of an automatic backup job. Check out more information about backing up MariaDB in Kubernetes for how I've handled MariaDB backups.
Installation
As with many complex Helm charts, I like to grab the values.yaml file to adjust the deployment settings. We can do that with the following commands:
helm show values oci://registry-1.docker.io/bitnamicharts/mariadb > values.yaml
Now we can start editing the file to our needs. Below is some examples where I have customized the settings. For example, I use Longhorn for block storage. You will obviously need to adjust to your needs.
values.yaml
...
global:
...
storageClass: "longhorn"
...
## @param architecture MariaDB architecture (`standalone` or `replication`)
##
architecture: replication #standalone
## MariaDB Authentication parameters
##
auth:
## @param auth.rootPassword Password for the `root` user. Ignored if existing secret is provided.
## ref: https://github.com/bitnami/containers/tree/main/bitnami/mariadb#setting-the-root-password-on-first-run
##
rootPassword: "YourSuperSecretPassword"
## @param auth.database Name for a custom database to create
## ref: https://github.com/bitnami/containers/blob/main/bitnami/mariadb/README.md#creating-a-database-on-first-run
##
database: intial
## @param auth.username Name for a custom user to create
## ref: https://github.com/bitnami/containers/blob/main/bitnami/mariadb/README.md#creating-a-database-user-on-first-run
##
username: "dbuser"
## @param auth.password Password for the new user. Ignored if existing secret is provided
##
password: "dbuser"
## @param auth.replicationUser MariaDB replication user
## ref: https://github.com/bitnami/containers/tree/main/bitnami/mariadb#setting-up-a-replication-cluster
##
replicationUser: replicator
## @param auth.replicationPassword MariaDB replication user password. Ignored if existing secret is provided
## ref: https://github.com/bitnami/containers/tree/main/bitnami/mariadb#setting-up-a-replication-cluster
##
replicationPassword: "YourSuperSecretPassword"
...
primary:
...
resourcesPreset: "medium"
...
secondary:
...
resourcesPreset: "medium"
...
Deploy the Chart
Now that we've adjusted our values.yaml file we can deploy the chart. I like to keep these as bash scripts so I can easily redeploy the chart as I make configuration changes
build-mariadb.sh
#!/bin/bash
helm upgrade --install --namespace database \
mariadb oci://registry-1.docker.io/bitnamicharts/mariadb \
-f values.yaml
Creating Databases for Applications
Now you can simply create new databases as needed for all of your MariaDB or MySQL enabled application. The process is straightforward: First, using Adminer, or any other MariaDB client of your liking execute the following (after making the appropriate changes)
CREATE DATABASE 'db_name';
CREATE USER 'db_user'@% IDENTIFIED BY 'YourSuperSecretPassword';
GRANT ALL PRIVILEGES ON 'db_name.* TO 'user1'@%;
FLUSH PRIVILEGES;
This will create a database and user for your application and give that role ownership of the database which should allow the consuming application everything it'll need to function.