在Kubernetes中,我如何才能有一个访问模式以一次允许一个吊舱写作,而许多豆荚只能读取?
我试图定义一个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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是请求
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) andReadOnlyMany
(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).