gpt4 book ai didi

kubernetes - 从具有不同模式的多个 pod 访问 kubernetes 存储 - 一个 pod ReadWrite,其他 pod ReadOnly

转载 作者:行者123 更新时间:2023-12-02 11:32:23 25 4
gpt4 key购买 nike

我有一个 pod 需要将数据持久保存到 pod 外部的位置。我认为persistentVolume 是一个好主意。名为 writerPod 的 pod 需要对该卷进行读写访问。
多个其他 Pod(我称它们为 readingPod)需要读取 writerPod 保存的文件。
是否可以有两个绑定(bind)相同 PersistentVolume 的 persistentVolumeClaims (PVC)(仅在 accessMode ReadWriteOnce 和 ReadOnlyMany 上有所不同)?

最佳答案

PVC 可以配置多个 accessMode(ReadOnlyMany 和 ReadWriteOnce):

  accessModes:
- ReadWriteOnce
- ReadOnlyMany
但是,顾名思义,您可以在 ReadOnlyMany (AKA ROX) 中将磁盘挂载到多个 pod,但一次只能有一个 pod 在 ReadWriteOnce 模式下使用该磁盘 (AKA RWO)。
如果您的 readingPod 仅在您的 writerPod 写入其数据后才启动 - 您可以使用相同的 PVC,只需确保安装 PVC 时将 readOnly 标志设置为 true,例如:
volumes:
- name: test-volume
persistentVolumeClaim:
claimName: my-pvc
readOnly: true
如果您使用支持 ReadWriteMany 访问模式的云提供商(不幸的是,Google 现在不是其中之一)它当然适合所有场景。查看 official documentation检查每个平台上支持的模式。

关于kubernetes - 从具有不同模式的多个 pod 访问 kubernetes 存储 - 一个 pod ReadWrite,其他 pod ReadOnly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62942395/

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