I am mounting an NFS file system directory from my Kubernetes pod, this is the PV yaml:
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-jenkins-pv
namespace: infrastrcuture
spec:
capacity:
storage: 8Gi
accessModes:
- ReadWriteOnce
mountOptions:
- vers=4.0
nfs:
server: "192.168.31.2"
path: "/home/dolphin/data/k8s/monitoring/infrastructure/jenkins"
persistentVolumeReclaimPolicy: Retain
and this is my NFS /etc/exports
file:
[dolphin@MiWiFi-R4CM-srv ~]$ cat /etc/exports
/ *(rw,fsid=0,sync,insecure_locks,insecure,no_root_squash)
/home/dolphin/data/k8s/monitoring/infrastructure/jenkins *(rw,fsid=1000,sync,insecure_locks,insecure,no_root_squash)
why the nfs server give me tips No such file or directory
? what should I do to fix? this is the full error log:
MountVolume.SetUp failed for volume "nfs-jenkins-pv" : mount failed: exit status 32 Mounting command: systemd-run Mounting arguments: --description=Kubernetes transient mount for /var/lib/kubelet/pods/fbbd2507-3c3b-49fa-a646-46748290f007/volumes/kubernetes.io~nfs/nfs-jenkins-pv --scope -- mount -t nfs -o vers=4.0 192.168.31.2:/home/dolphin/data/k8s/monitoring/infrastructure/jenkins /var/lib/kubelet/pods/fbbd2507-3c3b-49fa-a646-46748290f007/volumes/kubernetes.io~nfs/nfs-jenkins-pv Output: Running scope as unit: run-rde3824064fc74a3c91262071353346d3.scope mount.nfs: mounting 192.168.31.2:/home/dolphin/data/k8s/monitoring/infrastructure/jenkins failed, reason given by server: No such file or directory
I define my /etc/exports
file like this:
[dolphin@MiWiFi-R4CM-srv alertmanager]$ cat /etc/exports
/home/dolphin/data/k8s *(rw,fsid=0,sync,insecure_locks,insecure,no_root_squash)
/home/dolphin/data/k8s/infrastructure/jenkins *(rw,fsid=1000,sync,insecure_locks,insecure,no_root_squash)
/home/dolphin/data/k8s/monitoring/alertmanager *(rw,fsid=1001,sync,insecure_locks,insecure,no_root_squash)
and the PV yaml like this:
apiVersion: v1
kind: PersistentVolume
metadata:
name: nfs-jenkins-pv
namespace: infrastrcuture
spec:
capacity:
storage: 8Gi
accessModes:
- ReadWriteOnce
mountOptions:
- vers=4.0
nfs:
server: "192.168.31.2"
path: "/infrastructure/jenkins"
persistentVolumeReclaimPolicy: Retain
works.