<p>I have 2 pods inside a single deployment yaml of kubernetes</p>
<p>one for code base and php-fpm together</p>
<p>one for nginx</p>
<p>how to share the code base folder to nginx ?</p>
<p>i dont expect to see any answer that using init command to copy the folder from pod to pod</p>
<p>EDIT
i also try to split frontend service (nginx) and backend service (fpm and the code), but as the application itself require complex nginx rewrite rules, therefore it wont work for my case</p>
<p>BUT according to this repo -&gt; <a href="https://gist.github.com/matthewpalmer/741dc7a4c418318f85f2fa8da7de2ea1" rel="nofollow noreferrer">https://gist.github.com/matthewpalmer/741dc7a4c418318f85f2fa8da7de2ea1</a></p>
<p>it seem not possible to do it without COPY, but copy is super slow if u hv large file base</p>
<p>i wanna do the similar thing as same as docker-compose volume</p>

user192344
<p>As far as I can suggest based on the information you've given you have the following options:</p>
<p>a. Build a newer image of the Nginx image as your <code>BASE</code> image and copy all your source code to that image. Then reference that image in the Kubernetes <code>Deployment</code>.</p>
<p>OR</p>
<p>b. Add your source code to a <code>ConfigMap</code> and mount that in as a volume.</p>
<p>OR</p>
<p>c. Use an initContainer (Which you've already said you don't want to do).</p>
<p>All of these from my perspective seem wrong. I think it might be better to revisit why you're doing this and look at whether there are other options.</p>
<p>EDIT (More context now):</p>
<p>You don't need your code added to the Nginx container.</p>
<p>You just need to have the host resolvable. This can be achieved by adding a <code>Service</code> that points at your PHP code with the same name as you've defined in the <code>upstream</code> of the Nginx.</p>
<p>Look at this article: <a href="https://kubernetes.io/docs/tasks/access-application-cluster/connecting-frontend-backend/#creating-the-frontend" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/access-application-cluster/connecting-frontend-backend/#creating-the-frontend</a></p>
