MariaDB Server is one of the most popular open source relational databases. Itβs made by the original developers of MySQL. It is part of most cloud offerings and the default in most Linux distributions.
MariaDB-operator charm deploying and managing MariaDB on Kubernetes.
This charm has the following features:
- Add one more MariaDB units
- Config port of MariaDB
- Provide a database relation for any MariaDB client
- Allow to config the port mariadb will be listening on
- To restart mariadb service
- To backup database
- To list database backups
- To restore database from a specified backup
$ git clone https://github.com/mullumaus/mariadb-operator
$ cd mariadb-operator
$ charmcraft pack
Created 'mariadb.charm'.
$juju deploy ./mariadb.charm --resource mariadb-image=mariadb
$ juju status
Model Controller Cloud/Region Version SLA Timestamp
development micro microk8s/localhost 2.9.0 unsupported 20:52:16+10:00
App Version Status Scale Charm Store Channel Rev OS Address Message
mariadb mariadb active 1 mariadb local 31 kubernetes
Unit Workload Agent Address Ports Message
mariadb/0* active idle 10.1.49.14
$ juju run-action mariadb/0 backup --wait
unit-mariadb-0:
UnitId: mariadb/0
id: "111"
results:
message: backup /data/db/20210522-122411-backup.sql.gz
status: completed
timing:
completed: 2021-05-22 12:24:12 +0000 UTC
enqueued: 2021-05-22 12:24:12 +0000 UTC
started: 2021-05-22 12:24:12 +0000 UTC
$ juju run-action mariadb/0 --wait listbackup
unit-mariadb-0:
UnitId: mariadb/0
id: "115"
results:
message: 'backup files: [''20210522-122245-backup.sql.gz'', ''20210522-122411-backup.sql.gz'']'
status: completed
timing:
completed: 2021-05-22 12:24:31 +0000 UTC
enqueued: 2021-05-22 12:24:28 +0000 UTC
started: 2021-05-22 12:24:30 +0000 UTC
$ juju run-action mariadb/0 --wait restore
unit-mariadb-0:
UnitId: mariadb/0
id: "113"
results:
message: restored /data/db/20210522-122411-backup.sql.gz
status: completed
timing:
completed: 2021-05-22 12:24:21 +0000 UTC
enqueued: 2021-05-22 12:24:19 +0000 UTC
started: 2021-05-22 12:24:21 +0000 UTC
Create and activate a virtualenv with the development requirements:
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements-dev.txt
To check the logs generated by MariaDB
# The juju model in which MariaDB is installed corresponds to the k8s namespace
$ kubectl get pods --namespace development
NAME READY STATUS RESTARTS AGE
modeloperator-77b996d87b-hkj2t 1/1 Running 0 5h26m
mariadb-0 2/2 Running 0 21m
$kubectl logs mariadb-0 -c mariadb
The Python operator framework includes a very nice harness for testing
operator behaviour without full deployment. Just run_tests
:
./run_tests
https://hub.docker.com/_/mariadb
The MariaDB Charm is still a work in progress.
Here are some of the future features:
- Allow to backup/restore database
- Use keystone for authentication
- Use hacluster for HA