Configuring NFS CSI Driver for Session-State Preservation (NFS v4.1)
Follow these steps to verify server support, enforce mount options, and safely propagate storage changes across your Kubernetes cluster.
1. Check Server Support for NFS 4.1
Section titled “1. Check Server Support for NFS 4.1”Run this command on your NFS server to ensure version 4.1 is active and supported:
cat /proc/fs/nfsd/versions2. Enforce Mount Options via StorageClass
Section titled “2. Enforce Mount Options via StorageClass”Add these specific mount options to your Kubernetes StorageClass definition to enable session-state preservation and ensure data integrity:
- hard: Freezes I/O until the server returns to prevent data corruption.
- nfsvers=4.1: Enables session-state preservation.
- timeo=600: Sets the timeout sequence length to 60 seconds.
- retrans=2: Defines the number of retries before backing off.
3. Rollout Restart the NFS CSI Driver Workloads
Section titled “3. Rollout Restart the NFS CSI Driver Workloads”Apply the configuration changes by restarting the controller deployment and the node daemonset in the cluster:
kubectl rollout restart deployment csi-nfs-controller -n kube-systemkubectl rollout restart daemonset csi-nfs-node -n kube-systemVerify Pod Status
Section titled “Verify Pod Status”Ensure the new driver pods are running successfully before proceeding to the storage layer:
kubectl get pods -n kube-system -l app.kubernetes.io/name=csi-driver-nfs4. Propagate Changes to the Storage Layer
Section titled “4. Propagate Changes to the Storage Layer”Existing volumes must be rotated sequentially for the new mount options to take effect on your application workloads:
- Delete the active PVC associated with the workload.
- Delete the associated Pod to trigger a fresh volume attachment.
- Wait for the pod to restart, let it provision/assign a new PVC, and copy your data back over.
- Repeat this process sequentially for all remaining pods using the storage layer.
Crunchy Data PGO (PostgreSQL Operator) Workloads
Section titled “Crunchy Data PGO (PostgreSQL Operator) Workloads”To prevent downtime and ensure replication consistency, follow a strict failover order for database clusters:
- Target Replica (Slave) Pods First:
- Delete the PVC for a replica pod.
- Delete the replica pod.
- Wait for the replica pod to restart, bind its new PVC, and successfully catch up/sync data from the primary master.
- Repeat this one-by-one for all replica pods.
- Target Primary (Master) Pod Last:
- Trigger a manual switchover using PGO tools to demote the primary and safely promote a newly updated replica to master.
- Once demoted, delete the old master PVC and pod.
- Allow the old master to spin back up as a synchronized replica under the new mount settings.
Apache Kafka Workloads
Section titled “Apache Kafka Workloads”For Kafka clusters (especially Kraft or Zookeeper-based setups), always upgrade data workers before management planes to prevent cluster partition split-brains:
- Target Broker Pods First:
- Process Kafka brokers one-by-one.
- Delete the broker PVC and its matching pod.
- Wait for the broker to restart, attach the new PVC, and completely finish replicating missing partition log segments from the active ISR (In-Sync Replicas) list.
- Proceed to the next broker only after the current one is reporting fully healthy/synchronized.
- Target Controller Pods Last:
- Once all data brokers are updated, cycle the Kraft controllers one at a time.
- Delete the controller PVC and pod.
- Wait for the node to rejoin the quorum before moving to the next controller.
Dapr Infrastructure Workloads
Section titled “Dapr Infrastructure Workloads”For stateful Dapr system services, cycle the actor placement tracking engine before updating the job scheduling plane to maintain continuous actor routing:
- Target Placement Pods First:
- Delete the PVC and pod for the Dapr placement service.
- Wait for the placement pod to fully restart, claim its new volume, and reconstruct the actor placement tables.
- If running a multi-node high-availability placement quorum, cycle them one-by-one.
- Target Scheduler Pods Last:
- Once placement is stable, delete the PVC and pod for the Dapr scheduler service.
- Allow the scheduler to restart and re-sync its scheduled jobs and reminders under the updated storage configuration.
5. Cleanup: Remove Released PVs
Section titled “5. Cleanup: Remove Released PVs”After recreating the PVCs, the old Persistent Volumes (PVs) will be left in a Released status if your StorageClass reclaim policy is set to Retain. These must be cleaned up to prevent stale resource accumulation.
Option A: via Rancher UI
Section titled “Option A: via Rancher UI”- Navigate to your cluster in the Rancher Dashboard.
- In the left navigation menu, expand Storage and click on PersistentVolumes.
- Sort the list by the Status column to find all volumes marked as
Released. - Select the orphaned
Releasedvolumes. - Click Delete at the top or use the three-dot action menu to remove them.
Option B: via kubectl CLI
Section titled “Option B: via kubectl CLI”Alternatively, identify and purge the Released volumes directly using the terminal:
# List all PVs with a Released statuskubectl get pv | grep Released
# Delete specific released volumeskubectl delete pv <released-pv-name>