Accessing /docker-entrypoint-initdb.d from helm chart

4/17/2019

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 dir . ├── values-production.yml │ ├── files │ └── docker-entrypoint-initdb.d │ └── db.sql And run this command from the current dir

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.

-- shellwhale
kubernetes
kubernetes-helm
mariadb

2 Answers

4/18/2019

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
Source: StackOverflow

4/17/2019

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
Source: StackOverflow