title: Kubernetes PVC with AccessMode: ReadWriteOnce
body: <p>Our scenarios:</p>
  
  <p>We use ceph rbd to store some machine learning training dataset, the workflow as below:</p>
  
  <p>Create a ceph-rbd pvc pvc-tranining-data with AccessMode: ReadWriteOnce.<br>
  Create a write job with 1 pod to mount pvc-training-data and write training data in to pvc-training-data.<br>
  After writing the training data into pvc-training-data, the container will exit and the pvc-trainiing-data pvc is unmounted by k8s, the write job is done.<br>
  Create a read job with n pods where <code>n &gt;= 1</code> to mount pvc-training-data with <code>readOnly: true</code> to consume the training data.
  btw: we use k8s 1.6.1</p>
  
  <p>So far the workflow works well for our use scenarios, but I have some questions about PVC AccessMode and ceph rbd with AccessMode: ReadWriteOnce.</p>
  
  <blockquote>
    <ol>
    <li><p>How to understand AccessModes: ReadOnlyMany, ReadWriteOnce, ReadWriteMany?
    I think the usage scope is ReadOnlyMany &lt; ReadWriteOnce &lt; ReadWriteMay, so if I apply a PVC with AccessMode: ReadWriteOnce, it is ok I use
    it as AccessMode: ReadOnlyMany PVC, am I right?</p></li>
    <li><p>ceph rbd is a block device, each container(on different host) mount the same ceph rbd device will have their own filesystem, so the only allowed AccessMode is ReadOnlyMany or ReadWriteOnce, should we impose restrictions on ReadWriteOnce usage in k8s code?</p></li>
    </ol>
    
    <blockquote>
      <ol>
      <li>If a ReadWriteOnce pvc is mounted by a Pod with readOnly:false then no more Pod can mount this device, until it is unmounted.</li>
      <li>If a ReadWriteOnce pvc is mounted by a Pod with readOnly:true, it only can be mounted to other Pod as long as they set readOnly: true.</li>
      <li>there's no restrictions on container with in the same Pod, as they share the same filesystem from host ${KUBELET_ROOT}/plugins/{xx}/</li>
      </ol>
    </blockquote>
  </blockquote>