<p>My GKE deployment consists of N pods (possibly on different nodes) and a shared volume, which is <a href="https://kubernetes.io/docs/concepts/storage/dynamic-provisioning/" rel="nofollow noreferrer">dynamically provisioned</a> by <code>pd.csi.storage.gke.io</code> and is a Persistent Disk in GCP. I need to initialize this disk with data before the pods go live.</p>
<p>My problem is I need to set <code>accessModes</code> to <code>ReadOnlyMany</code> and be able to mount it to all pods across different nodes in read-only mode, which I assume effectively would make it impossible to mount it in write mode to the <code>initContainer</code>.</p>
<p>Is there a solution to this issue? <a href="https://stackoverflow.com/questions/57754103/how-to-pre-populate-a-readonlymany-persistent-volume">Answer to this question</a> suggests a good solution for a case when each pod has their own disk mounted, but I need to have one disk shared among all pods since my data is quite large.</p>

<p>With GKE 1.21 and later, you can enable the <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/filestore-csi-driver" rel="nofollow noreferrer">managed Filestore CSI driver</a> in your clusters.  You can enable the driver for new clusters</p>
<pre><code>gcloud container clusters create CLUSTER_NAME \
    --addons=GcpFilestoreCsiDriver ...
</code></pre>
<p>or update existing clusters:</p>
<pre><code>gcloud container clusters update CLUSTER_NAME \
   --update-addons=GcpFilestoreCsiDriver=ENABLED
</code></pre>
<p>Once you've done that, create a storage class (or have or platform admin do it):</p>
<pre><code>apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: filestore-example
provisioner: filestore.csi.storage.gke.io
volumeBindingMode: WaitForFirstConsumer
allowVolumeExpansion: true
parameters:
  tier: standard
  network: default
</code></pre>
<p>After that, you can use PVCs and dynamic provisioning:</p>
<pre><code>kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: podpvc
spec:
  accessModes:
  - ReadWriteMany
  storageClassName: filestore-example
  resources:
    requests:
      storage: 1Ti
</code></pre>
