<p>I'm building a helm chart with a MySQL dependency. It's being set up okay when empty, but I want to run an <code>sh</code> file on the pod that would copy some data from somewhere else. For this I want to use the <code>initializationFiles</code> constructions from the documentation <a href="https://github.com/helm/charts/tree/master/stable/mysql" rel="nofollow noreferrer">https://github.com/helm/charts/tree/master/stable/mysql</a></p>
<p>My values.yaml part related to this dependendency looks like this:</p>
<pre><code>mysql:
  mysqlRootPassword: somePass
  mysqlPassword : somePass
  mysqlUser: user
  appPassword: somePass
  initializationFiles:
    db.sh: |-
      #!/bin/sh
      touch dump.sql
</code></pre>
<p>Looks like the code under <code>initializationFiles</code> stanza is tried to be executed and causes the pod to fail. Since this stanza is executed only once by design, the second attempt succeeds, and when the pod is running I don't see any new file when I do <code>kubectl exec -it pod_name -- bash -c ls</code></p>
<p>I have tried this:</p>
<pre><code>...
  initializationFiles:
    - db.sh
</code></pre>
<p>and put the db.sh file in the same folder as <code>values.yaml</code>, but this still didn't work.
What is the correct way to execute an <code>sh</code> file when the dependency MySQL pod is being set up?
Kubernetes version 1.17, helm 3.5.0</p>
<p>I see that the file is actually copied to the <code>docker-entrypoint-initdb.d</code>, but it's not executed, no new file created.</p>
<pre><code>root@mypod:/docker-entrypoint-initdb.d# ls -la
lrwxrwxrwx 1 root root 12 Mar  6 00:14 db.sh -&gt; ..data/db.sh
root@mypod:/docker-entrypoint-initdb.d# cat db.sh
#!/bin/sh
touch dump.sql
</code></pre>
<p>I've tried to run the file manually, and got permission denied:</p>
<pre><code>root@mypod:/# ./docker-entrypoint-initdb.d/db.sh
bash: ./docker-entrypoint-initdb.d/db.sh: Permission denied
</code></pre>
<p>If I change my command to <code>echo test</code> then the sh file is executed, I can see this in the logs of the pod. Looks like changing the filesystem is prohibited, but doing <code>touch /dump.sql</code> or <code>touch /home/dump.sql</code> doesn't work either.</p>

Battle_Slug
<p>MUAHAHA I did it.
The scripts inside <code>./docker-entrypoint-initdb.d/</code> are executed by the <code>mysql</code> user.</p>
<p>After poking around inside the pod I've found a directory for which the <code>mysql</code> user has write permissions. So I just write the file there and delete afterwards to initialize the dbs.
Now the whole stanza looks like this:</p>
<pre><code>mysql:
  mysqlRootPassword: myPass
  mysqlPassword : myPass
  mysqlUser: user
  appPassword: myPass
  initializationFiles:
    db.sh: |-
      #!/bin/sh
      mysqldump -h remoteDbUrl -u remoteUser -pRemotePass --databases db1 db2 &gt; /var/lib/mysql/dump.sql
      mysql -uroot -pmyPass &lt; /var/lib/mysql/dump.sql
      rm /var/lib/mysql/dump.sql
      echo &quot;GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' IDENTIFIED BY 'myPass';&quot; | mysql -uroot -pmyPass

</code></pre>
