Kubernetes
GKE
Persistent Volume
Multi-Pod Mounting
Cloud Storage

GKE right way to mount same PV on multiple pods

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Understanding Persistent Volumes (PVs) on GKE

Google Kubernetes Engine (GKE) is a managed Kubernetes service that streamlines the deployment, management, and scaling of containerized applications using Google’s infrastructure. One of the core features of Kubernetes is its ability to manage storage resources using Persistent Volumes (PVs). In GKE, these volumes are often required to store application state or data that needs to persist outside of a pod's lifecycle. Understanding the right way to mount the same PV to multiple pods is crucial for achieving efficiency and reliability in your application deployment.

Technical Explanation of PVs and Multi-Pod Mounting

Persistent Volumes Basics

A Persistent Volume (PV) in Kubernetes is a piece of storage that has been provisioned for use by a Kubernetes cluster. PVs are not namespaced, and they have a lifecycle independent of any individual pod that uses them. Volumes can exist on various storage systems, including Network File System (NFS), cloud provider-based volumes (like Google Persistent Disk in GKE), and more.

Mounting PVs Across Multiple Pods

Kubernetes provides flexibility in how PVs are accessed by pods. The `accessModes` field in a PersistentVolumeClaim (PVC) allows you to specify how a volume can be mounted. The common access modes include:

  • ReadWriteOnce (RWO): The volume can be mounted as read-write by a single node.
  • ReadOnlyMany (ROX): The volume can be mounted read-only by many nodes.
  • ReadWriteMany (RWX): The volume can be mounted as read-write by many nodes.

For scenarios where multiple pods need simultaneous read-write access to the same Persistent Volume, the `ReadWriteMany` (`RWX`) mode is most applicable. This mode is especially useful for distributed applications requiring shared storage.

Example: Using Google Cloud Filestore for `RWX`

Google Cloud Filestore provides a managed Network Attached Storage (NAS) solution built on NFS, which supports the `ReadWriteMany` mode. Here's a step-by-step example of configuring and using Cloud Filestore with GKE:

  1. Create a Filestore Instance: First, create a Cloud Filestore instance in your Google Cloud project. Ensure it's in the same region and VPC as your GKE cluster.
    • ReadWriteMany
    • ReadWriteMany
      • name: nfs-test-container
        • mountPath: "/mnt/nfs"
      • name: nfs-volume

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.