gee*_*ets 5 google-compute-engine kubernetes persistent-volumes
我有一个 pod,需要将数据持久保存到 pod 外的某个地方。我认为persistentVolume 是一个好主意。名为 writerPod 的 pod 需要对该卷进行读写访问。
多个其他 Pod(我称它们为 readingPods)需要读取 writerPod 保存的文件。
是否可以有两个都绑定相同 PersistentVolume 的persistentVolumeClaims (PVC)(仅在 accessMode ReadWriteOnce 和 ReadOnlyMany 中不同)?
PVC 可以配置多个 accessMode(ReadOnlyMany 和 ReadWriteOnce):
accessModes:
- ReadWriteOnce
- ReadOnlyMany
Run Code Online (Sandbox Code Playgroud)
但是,顾名思义,您可以将磁盘挂载到 ReadOnlyMany (AKA ROX
) 中的多个 pod,但一次只有一个 pod 可以以 ReadWriteOnce 模式 (AKA RWO
)使用该磁盘。
如果您的 readingPods 应该只在您的 writerPod 写入数据后才启动 - 您可以使用相同的 PVC,只需确保将 readOnly 标志设置为 true 来安装 PVC,例如:
volumes:
- name: test-volume
persistentVolumeClaim:
claimName: my-pvc
readOnly: true
Run Code Online (Sandbox Code Playgroud)
如果您使用的是支持 ReadWriteMany 访问模式的云提供商(不幸的是,Google 现在不是其中之一),它当然适合您在所有场景中。查看官方文档,查看各个平台支持的模式。
归档时间: |
|
查看次数: |
273 次 |
最近记录: |