For more information, refer to the documentation on persistent volume access modes.
To mount a pre-populated disk as ReadOnlyMany, you create a new
PersistentVolume and PersistentVolumeClaim for the disk with the
fields set to ReadOnlyMany:
apiVersion: v1 kind: PersistentVolume metadata: name: my-readonly-pv spec: storageClassName: "" capacity: storage: 10G accessModes: - ReadOnlyMany gcePersistentDisk: pdName: my-test-disk fsType: ext4
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: my-readonly-pvc spec: accessModes: - ReadOnlyMany resources: requests: storage: 30Gi
Then, when using this PVC in your workloads, you need to specify
true on the Pod specification:
volumes: - name: my-volume persistentVolumeClaim: claimName: my-readonly-pvc readOnly: true
Now, you can have multiple Pods on different nodes that can all mount this PVC in read-only mode. Note that you can't attach Persistent Disks in write mode on multiple nodes at the same time. See Deployments Vs. StatefulSets.