Customize a new MariaDB instance
The Bitnami MariaDB image supports the use of custom scripts to initialize a fresh instance.
Custom scripts may be specified using the initdbScripts parameter. Alternatively, an external ConfigMap may be created with all the initialization scripts and the ConfigMap passed to the chart via the initdbScriptsConfigMap parameter. Note that this will override the initdbScripts parameter.
The allowed extensions are:
These scripts are treated differently depending on their extension. While .sh scripts are executed on all the nodes, .sql and .sql.gz scripts are only executed on the primary nodes. This is because .sh scripts support conditional tests to identify the type of node they are running on, while such tests are not supported in .sql or sql.gz files.
When using a .sh script, you may wish to perform a “one-time” action like creating a database. This can be achieved by adding a condition in the .sh script to ensure that it is executed only on one node, as shown in the example below:
initdbScripts: my_init_script.sh: | #!/bin/sh if [[ $(hostname) == *primary* ]]; then echo "Primary node" mysql -P 3306 -uroot -prandompassword -e "create database new_database"; else echo "No primary node" fi