<p>I want to share a volume across pods in a node in GKE.</p>
<p>I am using Terraform to provision all of this and using GKE autoscaling but no auto-provsioning.</p>
<pre><code>cluster_autoscaling {
    enabled             = false
    autoscaling_profile = var.aggresive_node_autoscale ? &quot;OPTIMIZE_UTILIZATION&quot; : &quot;BALANCED&quot;
  }
</code></pre>
<p>Which means we will not get new node-pools created by GKE, just new nodes from the existing pools. Right?</p>
<p>My original idea was to attach a volume per node and then share that by creating a persistent volume.</p>
<p>I have failed to mount to such disks, so now I am trying to use the boot disk from the nodes.</p>
<p>From the <a href="https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/container_cluster#nested_node_config" rel="nofollow noreferrer">documentation</a> I understand that we can setup SSD disks as boot disk</p>
<pre><code>    disk_size_gb = 256
    disk_type = &quot;pd-ssd&quot;
</code></pre>
<p>And I want to make this boot disk usable as a <a href="https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/persistent_volume_v1#local" rel="nofollow noreferrer">Local Persistent Volume</a></p>
<p>From what I see, the boot disk have the same name as the node pool, so I can use that to reference them</p>
<pre><code>data &quot;google_compute_disk&quot; &quot;gke_boot_disk&quot; {
  name    = google_container_node_pool.cpu_pool_n2_highmem_8.name
  project = local.project_id
  zone    = var.google_zone
}
</code></pre>
<p>And then how would I actually create the persistent disk?</p>
<p>Should I approach this in a different way? Do you have any recommendations or a good read for how to share a local SSD across pods of a node in GKE?</p>
<p>Thank you.</p>

chamini2
<blockquote>
<p>I want to share a volume across pods in a node in GKE.</p>
</blockquote>
<p>You missed the checking concept <strong>K8s</strong> side.</p>
<p>As you are looking for multiple <strong>PODs</strong> to share the volume across nodes you have to go with the <strong>ReadWriteMany</strong> or <strong>ReadOnlyMany</strong>.</p>
<blockquote>
<p><strong>ReadWriteMany</strong> : The volume can be mounted as read-write by many nodes. PersistentVolume resources that are backed by Compute Engine
persistent disks don't support this access mode.</p>
</blockquote>
<p>Read more <strong>AccessMode</strong> : <a href="https://cloud.google.com/kubernetes-engine/docs/concepts/persistent-volumes#access_modes" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/concepts/persistent-volumes#access_modes</a></p>
<p>if you don't have a requirement of <strong>ReadWriteMany</strong> and just looking for <strong>ReadOnlyMany</strong> you can use the <strong>Disks</strong>.</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: PV_NAME
spec:
  storageClassName: &quot;STORAGE_CLASS_NAME&quot;
  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
</code></pre>
<p>Ref : <a href="https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/readonlymany-disks#pre-existing-persistent-disk" rel="nofollow noreferrer">https://cloud.google.com/kubernetes-engine/docs/how-to/persistent-volumes/readonlymany-disks#pre-existing-persistent-disk</a></p>
<p>If you are looking for <strong>ReadWriteMany</strong> i think you can't use <strong>Disk</strong> with this <strong>AccessMode</strong>. You have to move to <strong><a href="https://cloud.google.com/kubernetes-engine/docs/concepts/multishares" rel="nofollow noreferrer">Filestore</a></strong>.</p>
<p>Other alternatives are going with the</p>
<ul>
<li><strong><a href="https://www.gluster.org/" rel="nofollow noreferrer">GlusterFs</a></strong> or <strong><a href="https://min.io/" rel="nofollow noreferrer">Minio</a></strong> which in background uses the <strong>Disks</strong> and give you <strong>NFS</strong> option</li>
</ul>
<p>With this you can create the <strong>ReadWriteMany</strong> access mode <strong>PV/PVC</strong> and attach that to <strong>deployment</strong>.</p>
