kubernetes persistent volume accessmode

前端 未结 2 343
心在旅途
心在旅途 2021-01-03 20:49

It seems that Kubernetes supports 3 kinds of access mode for persistent volume: ReadWriteOnce, ReadOnlyMany, ReadWriteMany. I\'m reall

相关标签:
2条回答
  • 2021-01-03 21:03

    If a pod mounts a volume with ReadWriteOnce access mode, no other pod can mount it. In GCE (Google Compute Engine) the only allowed modes are ReadWriteOnce and ReadOnlyMany. So either one pod mounts the volume ReadWrite, or one or more pods mount the volume ReadOnlyMany.

    The scheduler (code here) will not allow a pod to schedule if it uses a GCE volume that has already been mounted read-write.

    (Documentation reference for those who didn't understand the question: persistent volume access modes)

    0 讨论(0)
  • 2021-01-03 21:23

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

    The access modes are:

    • ReadWriteOnce -- the volume can be mounted as read-write by a single node
    • ReadOnlyMany -- the volume can be mounted read-only by many nodes
    • ReadWriteMany -- the volume can be mounted as read-write by many nodes

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

    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.

    0 讨论(0)
提交回复
热议问题