<p>I have a pod in my AWS EKS Cluster that runs MySQL:5.7. I have an SQL file that initializes and populates the data for it. in a normal docker-compose, I will use a mount point for it in my docker-compose file: </p>

<pre><code>volumes:
  - ./&lt;path-to-my-config-directory&gt;:/etc/mysql/conf.d
  - ./&lt;path-to-my-persistence-directory&gt;:/var/lib/mysql
  - ./&lt;path-to-my-init.sql&gt;:/docker-entrypoint-initdb.d/init.sql
</code></pre>

<p>In EKS, I can create a storage class in which to save MySQL data. </p>

<p>How can I use my init.sql file (about 8GB) to initialize the MySQL pods running in the EKS cluster?</p>

<p><strong>Update:</strong> there is another question that explains how to do this if you have a small init file or have access to the Kubernetes host: <a href="https://stackoverflow.com/questions/45681780/how-to-initialize-mysql-container-when-created-on-kubernetes">How to initialize mysql container when created on Kubernetes?</a></p>

<p>In my case though, I am on AWS EKS and my init file is a few gigabytes, so any help would be greatly appreciated.</p>

Reza
<p>It's easy in Kubernetes too. You can do it as follow,</p>

<ol>
<li>Put your <code>init.sql</code> file into a <a href="https://kubernetes.io/docs/concepts/storage/volumes" rel="nofollow noreferrer">Kubernetes volume</a>.</li>
<li>Mount this volume into <code>/docker-entrypoint-initdb.d</code> directory of your mysql pod.</li>
</ol>

<p>Here, is an sample yaml file: <a href="https://gist.github.com/hossainemruz/76adcfdaf51adf2ab7ab8e9b2d5d3d87" rel="nofollow noreferrer">mysql-init-demo.yaml</a></p>

<p>You can also use an <code>init-container</code> to download <code>init.sql</code> file into a Kubernetes volume that is mounted on <code>/docker-entrypoint-initdb.d</code> directory of mysql container.</p>

<p><strong>UPD:</strong> As you have specified in update that the solution you have referred won't work for you. I think <code>init-container</code> approach will be best suited for you. Here, is how you can do:</p>

<ol>
<li>Create a pvc. Let it's name is <code>init-script</code>.</li>
<li><p>Now, add a <code>init-container</code> to your mysql pod. Mount this <code>init-script</code> pvc at some directory of this <code>init-container</code>. Configure your <code>init-container</code> such that it download your <code>init.sql</code> file on this directory.</p></li>
<li><p>Mount the <code>init-script</code> in mysql container at <code>/docker-entrypoint-initdb.d</code></p></li>
</ol>

<p>Let me know if you need any sample with <code>init-container</code> approach.</p>

<p><strong>UPD-2:</strong> I have added a sample for <code>init-container</code> approach. You can find it <a href="https://gist.github.com/hossainemruz/7926eb2660cc8a1bb214019b623e72ea" rel="nofollow noreferrer">here</a>.</p>
