I'm trying to make use of the new subPath feature implemented in this pull request (recently released in v1.3).
However, the output of mount shows it ignoring the subPath, mounting the same NFS directory for both volume mounts:
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)The relevant bits of my deployment YAML:
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-serverI had this problem when I was trying to update a Kubernetes 1.4 cluster using kubectl version 1.2. Try updating your kubectl and then running kubectl apply on the appropriate file.
I'm not 100% sure about this, as I'm using a configMap volume rather than NFS, but I had to make the mountPath match the subPath as seen below before it worked for me.
FYI, I'm using Kubernetes v1.4.5.
If I'm reading this correctly, you are wanting to:
/mnt/nfs/exports/apps/my-app/foo-resources such that it's path in the container is /home/share/foo/foo-resources./mnt/nfs/exports/apps/my-app/baz-resources such that it's path in the container is /home/share/bar/baz/baz-resources.Try this:
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-serverThe differences:
16c16
< - mountPath: /home/share/foo/foo-resources
---
> - mountPath: /home/share/foo
19c19
< - mountPath: /home/share/bar/baz/baz-resources
---
> - mountPath: /home/share/bar/baz