For more information, refer to the documentation on persistent volume access modes.
In order to use your disk as ReadOnlyMany, you must create a new Persistent
Volume and PersistentVolumeClaim for the disk with the
accessModes fields set
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.