2016-08-01 101 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