Kubernetes Storage Failures Usually Start on the Host or the NAS

In progress Kubernetes Linux

When a volume won't mount or a PVC stays Pending, the cause is rarely the manifest. It's usually the node that mounts the volume, the NAS that exports it, file ownership inside it, or a PV still remembering an old claim. These seven traps account for most of what I hit on bare metal.

1. The Node Lacks the NFS Client

The kubelet calls the host's mount. Without nfs-common on the node, mount doesn't understand IP:/path and fails with fsconfig() failed / exit status 32. Install nfs-common on every node that may run the pod.

2. The NAS Squashes Root

A dynamic NFS provisioner creates each volume's folder as root. Exports with root squash (the TrueNAS default) map root to nobody: Permission Denied, PVCs stay Pending. Map root to root (TrueNAS: Maproot User = root) on the export used by the provisioner.

3. The App Runs as Another User

Folders are created root:root, but many images drop to an unprivileged user (UID 1000 in the linuxserver.io images). Writes fail inside the container. Fix ownership once with an initContainer running chown 1000:1000 /data, set fsGroup in the pod's securityContext where the volume type supports it, or adjust permissions on the NAS.

Apps sharing one volume must also agree with each other. In my media stack, an app running as root created root:root folders that another app, running as UID 1000, then couldn't rename. The linuxserver.io images read PUID and PGID variables and drop to that user in their entrypoint; images that don't support those variables ignore them and stay root. runAsUser and runAsGroup in the pod's securityContext work for any image, as long as it doesn't need root at startup (to bind a port below 1024, or to chown its own files).

4. A Retained PV Refuses the New Claim

With persistentVolumeReclaimPolicy: Retain, deleting a PVC keeps the PV and its data, but the PV stays Released with the old claim's UID in spec.claimRef. A new PVC with the same name doesn't match that UID and won't bind. Clear the reference:

kubectl patch pv <pv-name> -p '{"spec":{"claimRef":null}}'

5. A Local Volume Is Tied to a Dead Node

local-path PVs carry a nodeAffinity to their node. If that node is gone for good, the rescheduled pod stays Pending with volume node affinity conflict. Delete the PVC (and accept losing that data) so the provisioner creates a new volume on a healthy node.

6. The Server Accepts Only the Exported Path

A PV whose nfs.path points to a folder inside the export can fail with mount.nfs: access denied by server, although the export itself mounts fine. Some NFS servers accept mounts only of the exact paths they export (FreeBSD's mountd does, unless the export allows all directories), and my TrueNAS share behaved this way. Mount the exported path in the PV, and give each app its folder with subPath in the pod's volumeMounts.

7. A PV's Backend Can't Be Edited, and Deleting It Waits for Its Users

Moving the NAS to another address means changing the PV's nfs.server or nfs.path, and the API refuses: spec.persistentvolumesource is immutable after creation. The PV has to be deleted and recreated. The deletion then hangs because of the protection finalizers: a PVC used by a pod isn't removed (kubernetes.io/pvc-protection), and neither is a PV bound to a PVC (kubernetes.io/pv-protection). Deleting the pod doesn't help while its Deployment starts a new one that takes the claim again. Work from the top down:

kubectl scale deploy <app> -n <ns> --replicas=0   # nothing uses the claim any more
kubectl delete pvc <pvc> -n <ns>
kubectl delete pv <pv>

Then apply the new PV and PVC, and scale back up. A freshly created PV has no claimRef, so trap 4 only bites if the old PV object is kept. Removing a finalizer by hand (kubectl patch pvc <pvc> -p '{"metadata":{"finalizers":null}}') skips the protection while a pod may still be writing: keep it for objects whose users are really gone.

References

Review cards

Flashcard What happens if a node lacks the NFS client `nfs-common`?

The kubelet will fail to mount the volume, showing errors like fsconfig() failed or exit status 32.

Flashcard A retained PV stays Released and won't bind a new PVC with the same name. Why, and how do you fix it?

Its spec.claimRef still holds the old claim's UID. Clear it with kubectl patch pv <pv> -p '{"spec":{"claimRef":null}}'; the new claim then gets the old data.

Flashcard How can an app running as another user handle folder ownership issues in a container?

By using an initContainer to run chown, setting fsGroup in the pod's securityContext, or adjusting permissions on the NAS.