<p>I understand that files / folders can be copied into a container using the command:</p>

<pre><code>kubectl cp /tmp/foo_dir &lt;some-pod&gt;:/tmp/bar_dir
</code></pre>

<p>However, I am looking to do this in a yaml file</p>

<p>How would I go about doing this? (Assuming that I am using a deployment for the container)</p>

<p>The way you are going is wrong direction. Kubernetes does this with serveral ways.</p>

<p>first, think about configmap</p>

<p><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap" rel="noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap</a></p>

<p>You can easily define the configuration files for your application running in container</p>

<p>If you do know the files or folders is exist on worker nodes, you can use <code>hostPath</code> to mount it into container with nominated <code>nodeName: node01</code> in k8s yaml.</p>

<p><a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="noreferrer">https://kubernetes.io/docs/concepts/storage/volumes/#hostpath</a></p>

<p>if the files or folders are generated temporarily, you can use <code>emptyDir</code> </p>

<p><a href="https://kubernetes.io/docs/concepts/storage/volumes/#emptydir" rel="noreferrer">https://kubernetes.io/docs/concepts/storage/volumes/#emptydir</a></p>
