2016-08-01 67 views
4

我正在嘗試使用this拉取請求(最近在v1.3中發佈)中實現的新subPath功能。volumeMount子路徑不起作用

然而,mount輸出顯示它忽略了subPath,安裝同一NFS目錄兩個音量坐騎:

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) 

我的部署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-server 

回答

0

我當我嘗試使用kubectl版本1.2更新Kubernetes 1.4羣集時出現此問題。嘗試更新您的kubectl,然後在適當的文件上運行kubectl apply

3

我不是100%確定這一點,因爲我使用的是一個configMap卷而不是NFS,但我必須使mountPath匹配subPath,如下所示,然後才能爲我工作。

僅供參考,我正在使用Kubernetes v1.4.5。

如果我正確地讀這篇文章,你是想:

  • 掛載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