MariaDB Operator
Useful commands for working with the MariaDB operator.
Docs: https://mariadb-operator.github.io/mariadb-operator/latest/
Repo: https://github.com/mariadb-operator/mariadb-operator
Connect to MariaDB for OpenStack as root user
Create a port forward on your local machine to the OpenStack MariaDB server pod:
(MacOS) Connect to the database from your Mac using the brew install mariadb
client:
# extract root password from the kubernetes secret, then connect
ROOTPASSWORD=$(kubectl get secret -n openstack mariadb -o json | jq -r '.data["root-password"]' | base64 -d) /usr/local/opt/mariadb/bin/mariadb -h 127.0.0.1 --skip-ssl -u root --password=$ROOTPASSWORD
Dump a MariaDB database
Create a port forward on your local machine to the OpenStack MariaDB server pod:
(MacOS) Dump the database from your Mac using the brew install mariadb
client:
# specify the db to dump
DB_TO_DUMP=ironic
#extract root password from the kubernetes secret
ROOTPASSWORD=$(kubectl get secret -n openstack mariadb -o json | jq -r '.data["root-password"]' | base64 -d)
# perform the db dump
/usr/local/opt/mariadb/bin/mariadb-dump -h 127.0.0.1 --skip-ssl -u root --password=$ROOTPASSWORD $DB_TO_DUMP | gzip > $DB_TO_DUMP.sql.gz
Restore from a point in time backup
This assumes you have backups enabled with regularly scheduled backups: https://github.com/mariadb-operator/mariadb-operator/blob/main/docs/BACKUP.md/#scheduling
Create a manifest with a point in time to restore from:
apiVersion: k8s.mariadb.com/v1alpha1
kind: Restore
metadata:
name: restore
spec:
mariaDbRef:
name: mariadb
backupRef:
name: backup
targetRecoveryTime: 2025-03-13T09:00:00Z
Apply the manifest:
Check the status:
Watch the restore logs: