Post Image

Kubernetes NFS Persistent Volume Mount Issues

If you are running Kubernetes on prem either with bare metal hardware or using your virtual machine infrastructure you will need to worry about other underlying packages that Kubernetes depends on for certain things. File system libraries are an example of something that could trip you up when using NFS. Assuming your PV and PVC are setup correctly to use an NFS share for your pods and when deploying you notice your pods wont start this may be your issue.

 

An example below if we describe our pv

 

$ kubectl describe pv <Persistent Volume>
~ Output Truncated ~
Events:
  Type     Reason       Age                   From               Message
  ----     ------       ----                  ----               -------
  Normal   Scheduled    4m41s                 default-scheduler  Successfully assigned default/nginx-95975fff6-6r97b to dlp-kube-01.corp.capitalcu.com
  Warning  FailedMount  2m38s                 kubelet            Unable to attach or mount volumes: unmounted volumes=[nfs-share], unattached volumes=[kube-api-access-wsf5q nginx-secret nfs-share]: timed out waiting for the condition
  Warning  FailedMount  31s (x10 over 4m41s)  kubelet            MountVolume.SetUp failed for volume "testpv" : mount failed: exit status 32
Mounting command: mount
Mounting arguments: -t nfs 10.204.255.47:/var/nfs/general/ /var/snap/microk8s/common/var/lib/kubelet/pods/0c3c0a5c-1252-47d4-a164-3421465c5ab8/volumes/kubernetes.io~nfs/testpv
Output: mount: /var/snap/microk8s/common/var/lib/kubelet/pods/0c3c0a5c-1252-47d4-a164-3421465c5ab8/volumes/kubernetes.io~nfs/testpv: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program.
  Warning  FailedMount  22s  kubelet  Unable to attach or mount volumes: unmounted volumes=[nfs-share], unattached volumes=[nfs-share kube-api-access-wsf5q nginx-secret]: timed out waiting for the condition

 

The key point here is on the second to last line where it says bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program. This is pointing that the underlying OS does not have the proper bineries to mount NFS. 

 

Install Binaries

All we need to do here is install the NFS binaries in order to properly mount it.

$ sudo apt-get install -y nfs-common

 

And after that you should be good to go.



Comments (0)
Leave a Comment