<p>I have kubernetes pod where I am mounting my app source code as git volume. I tried various setups for how to put the source code into the pod and git volume was the one I ended up with in the end.</p>

<p>But now I have an issue with data. My app has a files directory in it(empty) and I need to mount a volume(fuse) in there. But since the destination is located on the git volume I cannot do this. So I am wondering how should I redesign my app?</p>

<p>Should I build the app's source code directly into the image so that I can then mount the data volume into it or is there some way I can mount volume into another so that I do not have to adjust anything?</p>

<p>I cannot move the target directory elsewhere since it has to be accessible by the app in its directory and also from web.</p>

<p>What I usually do is add the sources to the docker image when building the image. This is a straight forward process and you can always see the images as a black box in terms of deployment. What this achieves is effectively decoupling the preparation of the image and deploying/updating at run time as two different processes. </p>

<p>I believe this is the reason why kubernetes makes it easy to perform rolling upgrades for rolling out new software versions by exchanging a complete image, rather than trying to fix up the contents of a container. It is as easy as using the following command: </p>

<p><code>kubectl set image deployment/my-nginx-deployment my-nginx-image=TagXX</code></p>

<p>Replacing images also ensures that any debris is cleaned up (e.g. growing logs, temporary files etc.) and it allows you to bring along way more changes instead of just changing sources (e.g. upgrading server software versions).</p>

<p>It also allows you to perform testing/staging based on the exact images and not only a code deployment on servers that may not be identical to production servers.</p>

<p>You can read up on it at <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/" rel="nofollow noreferrer">this page</a> under <code>Updating a Deployment</code>.</p>
