<p>I'm trying to make use of the new <code>subPath</code> feature implemented in <a href="https://github.com/kubernetes/kubernetes/pull/22575" rel="noreferrer">this</a> pull request (recently released in v1.3).</p>

<p>However, the output of <code>mount</code> shows it ignoring the <code>subPath</code>, mounting the same NFS directory for both volume mounts:</p>

<pre><code>nfs-server:/mnt/nfs/exports/apps/my-app on /home/share/foo type nfs4 (rw,relatime,vers=4.0,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.128.0.4,local_lock=none,addr=nfs-server)
nfs-server:/mnt/nfs/exports/apps/my-app on /home/share/bar/baz type nfs4 (rw,relatime,vers=4.0,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=10.128.0.4,local_lock=none,addr=nfs-server)
</code></pre>

<p>The relevant bits of my deployment YAML:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: app
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: app
    spec:
      containers:
      - name: app
        image: my-org/my-app:latest
        volumeMounts:
        - mountPath: /home/share/foo
          name: nfs
          subPath: foo-resources
        - mountPath: /home/share/bar/baz
          name: nfs
          subPath: baz-resources
      volumes:
      - name: nfs
        nfs:
          path: /mnt/nfs/exports/apps/my-app
          server: nfs-server
</code></pre>

<p>I'm not 100% sure about this, as I'm using a <code>configMap</code> volume rather than NFS, but I had to make the <code>mountPath</code> match the <code>subPath</code> as seen below before it worked for me.</p>

<p>FYI, I'm using Kubernetes v1.4.5.</p>

<p>If I'm reading this correctly, you are wanting to:</p>

<ul>
<li>Mount the NFS file or directory <code>/mnt/nfs/exports/apps/my-app/foo-resources</code> such that it's path in the container is <code>/home/share/foo/foo-resources</code>.</li>
<li>Mount, the NFS file or directory <code>/mnt/nfs/exports/apps/my-app/baz-resources</code> such that it's path in the container is <code>/home/share/bar/baz/baz-resources</code>.</li>
</ul>

<p>Try this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: app
spec:
  replicas: 1
  template:
    metadata:
      labels:
        name: app
    spec:
      containers:
      - name: app
        image: my-org/my-app:latest
        volumeMounts:
        - mountPath: /home/share/foo/foo-resources
          name: nfs
          subPath: foo-resources
        - mountPath: /home/share/bar/baz/baz-resources
          name: nfs
          subPath: baz-resources
      volumes:
      - name: nfs
        nfs:
          path: /mnt/nfs/exports/apps/my-app
          server: nfs-server
</code></pre>

<p>The differences:</p>

<pre><code>16c16
&lt;         - mountPath: /home/share/foo/foo-resources
---
&gt;         - mountPath: /home/share/foo
19c19
&lt;         - mountPath: /home/share/bar/baz/baz-resources
---
&gt;         - mountPath: /home/share/bar/baz
</code></pre>
