Kubernetes 持久卷访问模式 [英] kubernetes persistent volume accessmode

查看:47
本文介绍了Kubernetes 持久卷访问模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎Kubernetes支持3种持久卷访问模式:ReadWriteOnceReadOnlyManyReadWriteMany.我真的很好奇使用 ReadWriteOnce 模式卷的 pod 的调度程序策略.例如,我创建了一个 RC 的 pod num=2,我猜这两个 pod 将被调度到同一主机中,因为它们使用具有 ReadWriteOnce 模式的卷?很想知道这部分的源码.

It seems that Kubernetes supports 3 kinds of access mode for persistent volume: ReadWriteOnce, ReadOnlyMany, ReadWriteMany. I'm really curious about the scheduler strategy for a pod which uses the ReadWriteOnce mode volume. For example, I created an RC which have pod num=2, I guess the two pods will be scheduled into the same host because they use the volume that has ReadWriteOnce mode? I really want to know the source code of this part.

推荐答案

我认为赞成的答案是错误的.根据关于访问模式

I think the upvoted answer is wrong. As per Kubernetes docs on Access Modes

访问模式为:

  • ReadWriteOnce -- 卷可以由单个节点以读写方式挂载
  • ReadOnlyMany -- 卷可以被多个节点以只读方式安装
  • ReadWriteMany -- 卷可以被多个节点以读写方式挂载

所以今天定义的 AccessModes 只描述了节点附加(而不是 pod 挂载)语义,并不强制执行任何操作.

So AccessModes as defined today, only describe node attach (not pod mount) semantics, and doesn't enforce anything.

所以为了防止两个 pod 挂载同一个 PVC,即使它们被安排在同一个节点上运行,你可以使用 pod anti-affinity.这与不在同一节点上调度的 2 个 pod 上挂载一个卷不同.但是反亲和性可用于要求调度程序不要在同一节点上运行 2 个 Pod.因此,它可以防止将一个卷安装到 2 个 pod 中.

So to prevent two pods mount the same PVC even if they are scheduled to be run on the same node you can use pod anti-affinity. It is not the same as not to mount one volume to 2 pods scheduled on the same node. But anti-affinity can be used to ask scheduler not to run 2 pods on the same node. Therefore it prevents mounting one volume into 2 pods.

这篇关于Kubernetes 持久卷访问模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆