Lack of submath volumeMount not working

I am trying to use a new function subPathimplemented in this pull request (recently released in version 1.3).

However, the output mountshows that it ignores subPathmounting the same NFS directory for both volumes:

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)

Relevant bits of my YAML deployment:

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
+4
source share
2 answers

I'm not 100% sure, because I use the configMapvolume, not NFS, but I had to make a mountPathmatch subPath, as shown below, before it worked for me.

FYI, I am using Kubernetes v1.4.5.

If I read this correctly, you want:

  • NFS /mnt/nfs/exports/apps/my-app/foo-resources , /home/share/foo/foo-resources.
  • NFS /mnt/nfs/exports/apps/my-app/baz-resources , /home/share/bar/baz/baz-resources.

:

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

:

16c16
<         - mountPath: /home/share/foo/foo-resources
---
>         - mountPath: /home/share/foo
19c19
<         - mountPath: /home/share/bar/baz/baz-resources
---
>         - mountPath: /home/share/bar/baz
+3

, Kubernetes 1.4 kubectl 1.2. kubectl, kubectl apply .

0

Source: https://habr.com/ru/post/1649774/


All Articles