从kubernetes pod挂载nfsv4时没有此类文件或目录

时间:2020-07-20 14:45:11

标签: kubernetes

我正在从Kubernetes容器中挂载NFS文件系统目录,这是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

这是我的NFS /etc/exports文件:

[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)

为什么NFS服务器会给我提示No such file or directory?我该怎么办?这是完整的错误日志:

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

1 个答案:

答案 0 :(得分:1)

我这样定义/etc/exports文件:

[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)

以及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: "/infrastructure/jenkins"
  persistentVolumeReclaimPolicy: Retain

有效。