Get the code here https://github.com/bitsector/gke-multi-node-shared-volume and follow along.

Why should you care:

Using a shared multi-node ReadWriteMany (RWX) volume in a GKE cluster is highly advantageous for applications that require scalability and shared data access. RWX volumes enable multiple pods across different nodes to simultaneously read from and write to the same persistent storage, making them ideal for distributed systems, collaborative workloads, and horizontally scalable applications. For instance, content management systems, data analytics pipelines, and media processing workloads benefit from shared volumes as they centralize data access, reduce duplication, and simplify scaling. Additionally, RWX volumes are crucial for stateful applications where maintaining a single source of truth across multiple replicas is necessary. By leveraging solutions like Google Filestore or custom NFS setups, organizations can achieve efficient storage utilization while supporting high-performance workloads.

However, setting up RWX volumes in GKE comes with significant challenges, particularly in terms of complexity. Native GCP persistent disks do not support RWX access natively, requiring additional infrastructure such as managed Filestore instances or custom NFS servers. These setups often involve configuring network file systems (NFS), managing security contexts, and ensuring compatibility with Kubernetes workloads. For example, deploying an NFS server may require privileged access or additional compute resources, which can introduce security risks and operational overhead. Moreover, achieving optimal performance and cost efficiency often requires careful planning around resource allocation and scaling limits. These complexities make RWX volume setup a non-trivial task that demands expertise in both Kubernetes and cloud storage solutions.

What is Google Filestore:

Google Filestore is a fully managed file storage service offered by Google Cloud Platform (GCP). It provides network-attached storage (NAS) using the NFS protocol, allowing multiple virtual machines or Kubernetes pods to share the same file system. Filestore is designed for applications that require high-performance, scalable, and consistent file-based storage, such as data analytics, media rendering, and content management systems. It integrates seamlessly with GCP services like Compute Engine and Google Kubernetes Engine (GKE), making it an excellent choice for stateful workloads that need shared access to persistent data. With its ability to scale capacity dynamically without downtime, Filestore simplifies storage management for demanding applications.

The cost of using Filestore can be significant, especially for multi-node ReadWriteMany (RWX) access. Filestore pricing is based on provisioned capacity rather than actual usage, with a minimum size of 1 TiB per instance. For example, the Basic HDD tier starts at approximately $163 per month for 1 TiB, while the Premium SSD tier costs around $307 per month for the same capacity. This pricing structure can make Filestore expensive for smaller workloads or use cases with limited storage needs. Additionally, network traffic charges may apply if data is accessed across zones or regions, further increasing costs. While Filestore's scalability and performance justify its cost for enterprise-grade workloads, it may not be cost-effective for smaller projects.

Filestore implements operations like read and write via network traffic using the NFS protocol. When a client mounts a Filestore instance, all file operations are transmitted over the network between the client and the Filestore server. This means that performance is influenced by network latency and bandwidth. On Linux systems, the NFS mount behaves like a kernel-mounted file system but relies on network communication to handle data operations. While this approach ensures compatibility with standard NFS clients and supports multiple concurrent connections, it introduces potential latency compared to local disk operations. Proper configuration of network settings and mount options is essential to optimize performance for high-demand workloads.

Create a namespace:

kubectl create ns my-ns

Create the Filestore CSI driver:

gcloud container clusters update my-cluster \\
   --update-addons=GcpFilestoreCsiDriver=ENABLED --zone=us-central1-c

Create a Filstore instance, as described here:

Screenshot from 2025-03-05 23-15-24.png

Check for Filestore instances:

gcloud filestore instances list --project=my-project --zone=us-central1-c

You will see something like this: