在Kubernetes中,我如何才能有一个访问模式以一次允许一个吊舱写作,而许多豆荚只能读取?

发布于 2025-02-01 08:50:16 字数 589 浏览 2 评论 0原文

我试图定义一个PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: master-pvc
spec:
  accessModes:
    - ReadWriteOnce
    - ReadOnlyMany
  resources:
    requests:
      storage: 1Gi

需要阅读的访问的节点应该定义:

volumeMounts:
- name: mastervol
  mountPath: /data/master/
  readOnly: true

需要读写的大师,应该定义:

volumeMounts:
- name: mastervol
  mountPath: /data/master/

这是实现我想要的有效方法吗?

I tried to define a PVC:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: master-pvc
spec:
  accessModes:
    - ReadWriteOnce
    - ReadOnlyMany
  resources:
    requests:
      storage: 1Gi

The nodes that need readonly access should define:

volumeMounts:
- name: mastervol
  mountPath: /data/master/
  readOnly: true

The master that needs to read and write, should define:

volumeMounts:
- name: mastervol
  mountPath: /data/master/

Is this a valid way to achieve what i want?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一身软味 2025-02-08 08:50:16

这不是请求folumemount的节点,而是吊舱内的容器(许多POD可能以同一节点运行)。

PVC使用单个访问模式(即使它支持许多人)绑定到PV(另请参见访问模式)。因此,您不能在readwriteOnce(对于某些pods)和readonlymany(对于其他一些pods)的同时运行PVC。

如果您想支持1个作者和许多读者,一个解决方案是让他们使用readwriteonce卷,并确保所有pods在同一节点上运行的卷都安装了(例如,使用节点亲和力约束)。

It is not a node that requests a volumeMount, but a container inside a Pod (many Pods may run in same node).

A PVC is 1-1 bound to a PV using a single access mode (even it supports many) at a time (see also access modes). So, you cannot have a PVC operating at the same time as ReadWriteOnce (for some Pods) and ReadOnlyMany (for some other Pods).

If you want to support 1 writer and many readers, one solution is to let them use a ReadWriteOnce volume and ensure that all Pods run on the same node the volume is mounted (e.g by using node affinity constraints).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文