3
votes

I'm trying to mount a NFS into my Kubernetes pod.

I'm using Minikube on my localmachine & used to have a hostPath volume but it's performance was pretty bad (page load takes about 30 secs or longer)

I've setup my NFS server on my Mac like this:

echo "/Users/my-name/share-folder -alldirs -mapall="$(id -u)":"$(id -g)" $(minikube ip)" | sudo tee -a /etc/exports && sudo nfsd restart

and validated it with:

showmount -e

This shows:

Exports list on localhost:
/Users/my-name/share-folder  192.168.xx.x

I've setup / applied a persistentVolume as followed:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: default-sources-volume
spec:
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  storageClassName: standard
  nfs:
    server: 192.168.xx.x # Minikube gateway to host
    path: '/Users/my-name/share-folder'

I've setup / applied a persistentVolumeClaim as followed:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: sources-volume-claim
  namespace: default
spec:
  storageClassName: standard
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 10Gi

I can see the persistentVolume & persistentVolumeClaim in my Kubernetes dashboard. It even says that the persistentVolumeClaim is bound, however ...

When I applied my updated deployment.yaml file through the kubectl command, I keep seeing the error:

MountVolume.SetUp failed for volume "default-sources-volume" : mount failed: exit status 32 Mounting command: systemd-run Mounting arguments: --description=Kubernetes transient mount for /var/lib/kubelet/pods/f4b26fe1-9657-11e8-8f3d-e61688dc52f9/volumes/kubernetes.io~nfs/default-sources-volume --scope -- mount -t nfs 192.168.xx.x:/Users/my-name/share-folder /var/lib/kubelet/pods/f4b26fe1-9657-11e8-8f3d-e61688dc52f9/volumes/kubernetes.io~nfs/default-sources-volume Output: Running scope as unit: run-r1b76b36ffcb1409284e308b11c729744.scope mount.nfs: access denied by server while mounting 192.168.xx.x:/Users/my-name/share-folder

1
NFS server returns access denied. Try to allow connections to NFS server from 0.0.0.0Akar
Het, thanks for the reply. I already tried allowing every IP, but without success.mattyh88

1 Answers

1
votes

please try this in your '/etc/exports'
/Users/my-name/share-folder *(rw,fsid=0,async,no_subtree_check,no_auth_nlm,insecure,no_root_squash)

and
sudo exportfs -a

I find that insecure is the key.