liveBook · Manning

Readonlymany

As explained in Kubernetes in Action, Second Edition

ReadOnlyMany is a Kubernetes volume access mode that permits a volume to be mounted read-only by multiple nodes or pods concurrently.

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

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains access restrictions, dynamic provisioning, claim cloning, and pod mounting, but stops short of broader data-source types.
Examples
Uses a claim cloned from demo-read-write-once and BusyBox pods that list files from the shared read-only volume.
What it assumes
Assumes familiarity with PersistentVolumeClaims and dynamic provisioning while introducing data-source initialization for empty volumes.
What you can do after
Configure a ReadOnlyMany claim from another claim and mount it read-only in multiple pods.
How it connects
Links PersistentVolumeClaims, PersistentVolumes, dynamic provisioning, data sources, and pod volume mounts.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.