ReadOnlyMany is a Kubernetes PersistentVolume access mode that lets multiple nodes or pods mount a volume concurrently for reading, but not writing. section 10.2.4
Use ReadOnlyMany with dynamically provisioned storage by:
- Initializing the new, otherwise empty volume from an existing PersistentVolumeClaim through dataSourceRef. section 10.2.4
- Setting accessModes to ReadOnlyMany on the new PersistentVolumeClaim. section 10.2.4
- Mounting that claim with readOnly: true in each consuming pod. section 10.2.4
Clone data into a shared read-only volume
A PersistentVolumeClaim can specify kind: PersistentVolumeClaim and name: demo-read-write-once in dataSourceRef, request ReadOnlyMany, and provide initialized data to multiple reader pods. section 10.2.4
Listing 10.5 Initializing a PersistentVolumeClaim with another PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: demo-read-only-many
labels:
app: demo-read-only-many
spec:
resources:
requests:
storage: 1Gi
accessModes: #1
- ReadOnlyMany #1
dataSourceRef: #2
kind: PersistentVolumeClaim #2
name: demo-read-write-once #2
Shows the PersistentVolumeClaim manifest that requests ReadOnlyMany and initializes it from another claim. section 10.2.4
Listing 10.6 A pod using a shared PersistentVolume in read-only mode
apiVersion: v1
kind: Pod
metadata:
generateName: demo-read-only-many-
labels:
app: demo-read-only-many
spec:
volumes:
- name: volume
persistentVolumeClaim: #1
claimName: demo-read-only-many #1
readOnly: true #1
containers:
- name: main
image: busybox
command:
- sh
- -c
- |
echo "I can read from the volume; these are its files:" ; #2
ls /mnt/volume ; #2
sleep infinity #2
volumeMounts:
- name: volume
mountPath: /mnt/volume ...
Shows a pod mounting the shared claim with readOnly: true and listing its files. section 10.2.4
