1

My GKE deployment consists of N pods (possibly on different nodes) and a shared volume, which is dynamically provisioned by pd.csi.storage.gke.io and is a Persistent Disk in GCP. I need to initialize this disk with data before the pods go live.

My problem is I need to set accessModes to ReadOnlyMany 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 initContainer.

Is there a solution to this issue? Answer to this question 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.

Leonid Bor
  • 2,064
  • 6
  • 27
  • 47

2 Answers2

1

...I need to have one disk shared among all pods

You can try Filestore. First your create a FileStore instance and save your data on a FileStore volume. Then you install FileStore driver on your cluster. Finally you share the data with pods that needs to read the data using a PersistentVolume referring the FileStore instance and volume above.

gohm'c
  • 13,492
  • 1
  • 9
  • 16
  • Looks like a great solution, however, I have a company limitation which does not allow me to use `PersistentVolume`s. I can only use `PersistentVolumeClaim`s and dynamic provisioning – Leonid Bor Apr 24 '22 at 08:08
1

With GKE 1.21 and later, you can enable the managed Filestore CSI driver in your clusters. You can enable the driver for new clusters

gcloud container clusters create CLUSTER_NAME \
    --addons=GcpFilestoreCsiDriver ...

or update existing clusters:

gcloud container clusters update CLUSTER_NAME \
   --update-addons=GcpFilestoreCsiDriver=ENABLED

Once you've done that, create a storage class (or have or platform admin do it):

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

After that, you can use PVCs and dynamic provisioning:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: podpvc
spec:
  accessModes:
  - ReadWriteMany
  storageClassName: filestore-example
  resources:
    requests:
      storage: 1Ti
Gari Singh
  • 11,418
  • 2
  • 18
  • 41