<p>I use <code>configMap</code> to feed the <code>init.sql</code> script to initialise my Mysql container in the Kubernetes pod. While that works for most cases I am struggling to convert a larger <code>init.sql</code> file which is 12.2 MB. 
I use the following in <code>deployment.yaml</code> to mount the configMap.</p>

<pre><code>volumeMounts:
- name: init-volume
  mountPath: /docker-entrypoint-initdb.d
</code></pre>

<pre><code>volumes:
- name: init-volume
  configMap:
    defaultMode: 420
    name: init-volume
</code></pre>

<p>The command I use to create the configMap </p>

<pre><code>kubectl create configMap init-volume --from-file=init.sql
</code></pre>

<p>I get the error </p>

<pre><code>Error from server (RequestEntityTooLarge): Request entity too large: limit is 3145728
</code></pre>

<p>How can I increase this limit/or any other alternate to initialise my database?</p>

Vishakha Lall
<blockquote>
  <p>How can I increase this limit/or any other alternate to initialise my database?</p>
</blockquote>

<p>The <code>.d</code> nomenclature in that path means it will load <strong>all</strong> files found therein, so the solution is to chop up the <code>init.sql</code> into smaller chunks, name them so that they apply in the right order when viewed with <code>/bin/ls -1</code>, and stick each one into a configmap:</p>

<pre class="lang-sh prettyprint-override"><code>i=1
for fn in *.sql; do
   kubectl create configmap init-sql-$i --from-file="$fn"
   i=$(( i + 1 ))
done
</code></pre>

<p>then volume mount them into the directory</p>

<pre class="lang-yaml prettyprint-override"><code>volumeMounts:
- name: init-file-1
  mountPath: /docker-entrypoint-initdb.d/file-1.sql
- name: init-file-2
  mountPath: /docker-entrypoint-initdb.d/file-2.sql
# and so forth
</code></pre>
