2

I am trying to initialize a fresh instance of MariaDB (putting my .sql file inside /docker-entrypoint-initdb.d) using the official helm chart at https://github.com/helm/charts/tree/master/stable/mariadb#initialize-a-fresh-instance.

But I find the instructions quite unclear:

In order to execute the scripts, they must be located inside the chart folder files/docker-entrypoint-initdb.d so they can be consumed as a ConfigMap.

Since the only thing I do to set up the Mariadb cluster is using their helm install --name my-release stable/mariadb -f values-production.yaml I am quite confuse.

Where is this folder ?


Edit

I downloaded https://github.com/helm/charts/tree/master/stable/mariadb and placing (the whole folder) and placed my SQL file inside files/docker-entrypoint-initdb.d.

I then used helm package ./mariadb followed by helm install ./mariadb -f ./mariadb/values-production.yaml. But the master pod has "CrashLoopBackOff" as status.

Here are the master logs

==> ** Starting MariaDB setup **
==> Validating settings in MYSQL_*/MARIADB_* env vars..
==> Initializing mariadb database...
==> Persisted data detected. Restoring...
==> Loading user's custom files from /docker-entrypoint-initdb.d ...
==> Stopping mariadb...

I also tried this way, but the db keep crashing

kubectl create configmap db-scheme --from-file=db.sql
helm install --name db-test stable/mariadb -f .values-production.yml --set rootUser.password=ROOT_PASSWORD --set replication.password=REPLICATION_PASSWORD --set initdbScriptsConfigMap=db-scheme

Here are the logs :

image


Edit2

I created a folder named files/docker-entrypoint-initdb.d

My current directory:

.
├── values-production.yml
│
├── files
│   └── docker-entrypoint-initdb.d
│       └── db.sql

And run this command from the current directory:

helm install --name test stable/mariadb -f .\values-production.yml --set rootUser.password=ROOT_PASSWORD --set replication.password=REPLICATION_PASSWORD

MariaDB boots up but without my SQL tables.

Alexey Vazhnov
  • 1,291
  • 17
  • 20
shellwhale
  • 820
  • 1
  • 10
  • 34
  • 1
    Hi @shellwhale (great name btw), please refrain from pasting screenshots of code/logs. You may find some reasoning for this here: https://meta.stackoverflow.com/a/285557/11102471 – MWZ Apr 24 '19 at 14:18

2 Answers2

3

My issue is more complex than it seems : https://github.com/bitnami/bitnami-docker-mariadb/issues/182

Something apart, creating a configmap does indeed work :

kubectl create configmap db-scheme --from-file=db.sql

helm install --name db-test stable/mariadb -f .values-production.yml --set rootUser.password=ROOT_PASSWORD --set replication.password=REPLICATION_PASSWORD --set initdbScriptsConfigMap=db-scheme
shellwhale
  • 820
  • 1
  • 10
  • 34
  • 1
    This seems like the path of least resistance. The chart keeps linking to the galera docker image from bitnami, where you either need to mount a volume or actually copy your sql file into /docker-entrypoint-initdb.d folder and then use that custom image, but then you might have to maintain your own chart. – Meezaan-ud-Din Dec 22 '20 at 05:51
0

That chart is a bit awkward, but let me explain, They will create this configmap which reads info of that folder (relatively of the values.yaml path).

For your luck, you two more alternatives:

  • Pass the scripts you want inlined on your values.yaml (Line 122)
  • Creates aside a configmap with your scripts and refer the name on your values.yaml (Line 129)
gonzalesraul
  • 777
  • 3
  • 14
  • I don't get it. Am I supposed to clone the chart, place my .sql file inside the files/docker-entrypoint-initdb.d folder, run helm package and helm install ? Because that give me a CrashLoopBackOff – shellwhale Apr 17 '19 at 18:33
  • if you want to go with the default options, on your command `helm install --name my-release stable/mariadb -f values-production.yaml`, make sure you have a folder with the name `files` on your current dir with the scripts. – gonzalesraul Apr 18 '19 at 09:40
  • Please see my edit2. I created a folder with the name `files` Mariadb boots up but without my sql tables. – shellwhale Apr 18 '19 at 10:10