<p>Trying to move my services to K8s. I am using helm for that and I want to describe my example with issue:</p>
<p>I need to move few services with own Apache`s. Yes, I understand, that this is working something like:</p>
<p>external traffic -&gt; K8s nginx ingress -&gt; pod Apache</p>
<p>But I cant change it for now. Apache is working with PHP. So, I have deployment for two images: <code>php-fpm</code> and <code>Apache</code>. And, in this case, I need to share php files from my first php-fpm container with Apache.</p>
<p>For now - I am using shared <code>volumeMounts</code> to copying files from one container to second (all date is preparing/compiling in the first container, php-fpm, during the build):</p>
<pre><code>volumeMounts:
  - name: shared-files
    mountPath: /var/shared-www
</code></pre>
<p>And</p>
<pre><code>lifecycle:
  postStart:
    exec:
      command: [&quot;/bin/bash&quot;, &quot;-c&quot;, &quot;cp -r XXX /var/shared-www/&quot;]
</code></pre>
<p>And it is working, but I would like to find solution to have one common point, like a symlink, to store files. I want to have ability to change files in one place and have changed files in both containers.</p>
<p>Is it possible?</p>
<p>PS I am using AWS EKS. And I don`t want to use network storage (like a EFS).</p>

prosto.vint
<p>Why not use <a href="https://kubernetes.io/docs/concepts/storage/volumes/#using-subpath" rel="nofollow noreferrer">subPath</a> as per official documentation:</p>
<blockquote>
<p>it is useful to share one volume for multiple uses in a single pod.
The volumeMounts.subPath property specifies a sub-path inside the
referenced volume instead of its root.</p>
</blockquote>
<p>So instead of running the command something like (to share XXX towards):</p>
<pre><code>volumeMounts:
  - name: shared-files
    mountPath: /var/shared-www
    subpath: XXX
</code></pre>
<p>Update:</p>
<p>Kubernetes subpath vulnerability <a href="https://kubernetes.io/blog/2018/04/04/fixing-subpath-volume-vulnerability/" rel="nofollow noreferrer">article</a></p>
