A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/readonlymany-disks below:

Use persistent disks with multiple readers | Google Kubernetes Engine (GKE)

Use persistent disks with multiple readers

Stay organized with collections Save and categorize content based on your preferences.

This page explains how to add a persistent disk to your cluster using the ReadOnlyMany access mode. This mode allows multiple Pods on different nodes to mount the disk for reading.

For more information on this mode, refer to persistent volume access modes.

Requirements Format and populate a source persistent disk

To use a persistent disk in read-only mode, you must populate a source persistent disk with data, then either clone the volume or use a volume snapshot to move the data into a new ReadOnlyMany PersistentVolume.

  1. Create a PersistentVolume using an existing persistent disk or using dynamic provisioning.

  2. Format the disk and populate it with data. To format the disk, reference the disk as a ReadWriteOnce PersistentVolume in a Pod. GKE automatically formats the underlying disk, and lets the Pod write data to the disk. When the Pod starts, make sure the Pod writes the data you want to the disk.

Create a ReadOnlyMany PersistentVolume

You can create a ReadOnlyMany PersistentVolume using one of the following methods:

Volume snapshot
  1. Create a volume snapshot of the source PersistentVolume.

  2. Save the following PersistentVolumeClaim manifest as snapshot-pvc.yaml:

    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      namespace: PVC_NAMESPACE
      name: PVC_NAME
    spec:
      dataSource:
        apiGroup: snapshot.storage.k8s.io
        kind: VolumeSnapshot
        name: SNAPSHOT_NAME
      accessModes:
        - ReadOnlyMany
      storageClassName: premium-rwo
      resources:
        requests:
          storage: STORAGE_SIZE
    

    Replace the following:

  3. Apply the manifest to your cluster:

    kubectl apply -f snapshot-pvc.yaml
    

This creates a new PersistentVolumeClaim named PVC_NAME in your cluster, which GKE uses to dynamically provision a new PersistentVolume that contains the data from the snapshot of the source persistent disk.

Volume cloning

Before using volume cloning, make sure to familiarize yourself with the limitations of this approach.

  1. Save the following manifest as cloning-pvc.yaml:

    kind: PersistentVolumeClaim
    apiVersion: v1
    metadata:
      namespace: PVC_NAMESPACE
      name: PVC_NAME
    spec:
      dataSource:
        name: SOURCE_PVC
        kind: PersistentVolumeClaim
      accessModes:
        - ReadOnlyMany
      storageClassName: STORAGE_CLASS_NAME
      resources:
        requests:
          storage: STORAGE_SIZE
    

    Replace the following:

  2. Apply the manifest to your cluster:

    kubectl apply -f cloning-pvc.yaml
    

This creates a PersistentVolumeClaim named PVC_NAME that GKE uses to create a new PersistentVolume in ReadOnlyMany mode with the data in the source PersistentVolume.

For more detailed information about Volume Cloning, see Create clones of persistent volumes.

Pre-existing persistent disk
  1. Save the following manifest as preexisting-disk-pv-pvc.yaml:

    apiVersion: v1
    kind: PersistentVolume
    metadata:
      name: PV_NAME
    spec:
      storageClassName: "STORAGE_CLASS_NAME"
      capacity:
        storage: DISK_SIZE
      accessModes:
        - ReadOnlyMany
      claimRef:
        namespace: PVC_NAMESPACE
        name: PVC_NAME
      csi:
        driver: pd.csi.storage.gke.io
        volumeHandle: DISK_ID
        fsType: FS_TYPE
        readOnly: true
    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
      namespace: PVC_NAMESPACE
      name: PVC_NAME
    spec:
      storageClassName: "STORAGE_CLASS_NAME"
      volumeName: PV_NAME
      accessModes:
        - ReadOnlyMany
      resources:
        requests:
          storage: DISK_SIZE
    

    Replace the following:

  2. Apply the manifest to your cluster:

    kubectl apply -f preexisting-disk-pv-pvc.yaml
    

This creates a PersistentVolumeClaim named PVC_NAME and a PersistentVolume named PV_NAME in ReadOnlyMany mode.

For more detailed information about using a pre-existing persistent disk, see existing persistent disk.

Use the PersistentVolumeClaim in a Pod

You can now reference the new PersistentVolumeClaim in read-only mode in multiple Pods on multiple nodes at the same time. You cannot attach persistent disks in ReadWriteOnce mode to multiple nodes at the same time. For more information, refer to Deployments vs. StatefulSets.

In your Pod specification, you must specify readOnly: true in the volumeMounts section and the volumes section, such as in the following example:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: multi-read
  labels:
    app: web-server
spec:
  replicas: 3
  selector:
    matchLabels:
      app: web-server
  template:
    metadata:
      labels:
        app: web-server
    spec:
      containers:
      - name: web-server
        image: nginx
        volumeMounts:
        - mountPath: /test-mnt
          name: my-volume
          readOnly: true
      volumes:
      - name: my-volume
        persistentVolumeClaim:
          claimName: PVC_NAME
          readOnly: true
Note: Read-only ext3 and ext4 filesystems do not support journal playback. If the source persistent disk filesystem is marked as dirty when you clone or snapshot it, the data in your read-only persistent disk might be inconsistent or corrupt. The Compute Engine persistent disk CSI driver attempts to mount the disk normally. If the inability to playback the journal causes the volume mount to fail, the CSI driver automatically retries the mount with the noload option, which disables playback attempts on ext3 and ext4 filesystems. If the source filesystem was actually inconsistent at the moment it was cloned or snapshotted, the read-only mount will also be inconsistent. What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-02 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-02 UTC."],[],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4