gpt4 book ai didi

kubernetes - volumeMount subPath 不起作用

转载 作者:行者123 更新时间:2023-12-04 20:34:22 30 4
gpt4 key购买 nike

我正在尝试使用新的 subPaththis 中实现的功能拉取请求(最近在 v1.3 中发布)。

但是,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

最佳答案

我对此不是 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

    关于kubernetes - volumeMount subPath 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38697335/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com