⌂ Home

NFS with PV and PVC

Use an NFS server with Kubernetes persistent volumes to provide shared storage across Pods and nodes.

NFS is one of the clearest ways to teach shared Kubernetes storage because many Pods can mount the same directory, even when they run on different nodes.

Core Concepts

Repository YAML Files:
  • k8s/labs/storage/nfs-pv-pvc.yaml — NFS PV, PVC, and Pod manifest

Shared filesystem

An NFS server exports one directory that many Pods can mount through a PV and PVC.

ReadWriteMany teaching model

NFS is a practical way to demonstrate RWX behavior in labs and on-premises clusters.

Centralized data path

Data management, backup, and access control are organized around the exported server path.

NFS Integration Flow

1

Prepare the NFS server

Install the server, export a directory, and make sure cluster nodes can reach it.

2

Confirm client access

Install NFS client tools and verify a node can mount the exported path.

3

Create the PV

Point a PersistentVolume at the server IP and export path.

4

Bind the PVC

The claim requests shared storage and binds to the NFS-backed volume.

5

Mount in Pods

Many Pods can use the same underlying files across nodes and workloads.

Key point: When the lesson is shared writable access rather than simple persistence, NFS explains the behavior more clearly than HostPath.

Representative YAML

NFS PV

apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-pv
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  nfs:
    path: /mnt/nfs_share
    server: 192.168.1.100

PVC and Pod

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-pvc
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: nfs-pod
spec:
  containers:
  - name: nginx
    image: nginx
    volumeMounts:
    - name: nfs-volume
      mountPath: /usr/share/nginx/html
  volumes:
  - name: nfs-volume
    persistentVolumeClaim:
      claimName: nfs-pvc

HostPath vs NFS

TopicHostPathNFS
Data locationOne node filesystemNetwork share on a server
Multi-node accessNo practical shared accessYes, designed for it
RWX fitPoorStrong
Typical lessonLocal persistenceShared storage
Design hint: NFS is a very effective bridge from simple lab storage to more advanced shared-storage platforms.

How To Use It In Practice

Cross-node labs

Show that the same data remains visible even when Pods run on different nodes.

RWX demonstrations

Teach why some backends support shared writable access while others do not.

Shared file workloads

Use NFS when many Pods need to coordinate around common files, logs, or assets.