Challenge, Medium,  on  Kubernetes

Provision Dynamic NFS CSI Storage to Restore Stuck Deployments

Scenario

The audit-trail-writer deployment in the audit namespace runs 3 replicas where each pod continuously writes structured audit logs to a shared NFS volume on nfs-storage-server, capturing its own pod name, the node it is scheduled on, and its pod IP.

All pods are stuck in Pending because the deployment references a PersistentVolumeClaim named audit-trail-pvc that does not exist, and no StorageClass has been created to provision it.

The NFS server is already running on nfs-storage-server (172.16.0.5) at export path /srv/nfs/k8s, and the NFS CSI driver (nfs.csi.k8s.io) is already installed in the cluster.

Create the missing StorageClass and PersistentVolumeClaim to unblock the deployment and get all 3 pods writing audit logs to shared storage.


Task

1. Create a StorageClass named platform-nfs with the following specification:

  • Provisioner: nfs.csi.k8s.io
  • Parameters:
    • server: 172.16.0.5
    • share: /srv/nfs/k8s
  • Reclaim policy: Delete
  • Volume binding mode: Immediate
  • Allow volume expansion: true

2. Create a PersistentVolumeClaim named audit-trail-pvc in the audit namespace with the following specification:

  • StorageClass: platform-nfs
  • Access mode: ReadWriteMany
  • Storage request: 1Gi
Kubernetes pods writing audit logs to shared NFS storage using PVC and StorageClass

The audit-trail-writer pods mount the shared NFS-backed PVC (audit-trail-pvc) provisioned by the platform-nfs StorageClass and write logs to shared storage.

Once the PVC is bound, the stalled pods will automatically recover and start writing audit logs to the shared NFS volume on nfs-storage-server.

⏳ Wait up to 1 minutes for the environment to fully initialise before starting — NFS server setup and CSI driver installation run in the background.


Hint 1 — StorageClass

Create a StorageClass using the nfs.csi.k8s.io provisioner pointing to the NFS server on dev-machine:

parameters:
  server: 172.16.0.5
  share: /srv/nfs/k8s
reclaimPolicy: Delete
volumeBindingMode: Immediate
allowVolumeExpansion: true
Hint 2 — PersistentVolumeClaim

Use ReadWriteMany access mode and request 1Gi of storage — all 3 pods run on different nodes and must mount the same NFS volume simultaneously.

resources:
  requests:
    storage: 1Gi

Test Cases