Kubernetes解决NFS挂载报错的问题(CentOS版)

报错如下:


[root@node1 nfs]# kubectl describe pod nfs-client-provisioner-6f7bf77fd6-fbzhw -n nfs
Name:           nfs-client-provisioner-6f7bf77fd6-fbzhw
Namespace:      nfs
Priority:       0
Node:           node4/192.168.23.63
Start Time:     Thu, 06 Jan 2022 03:50:28 -0500
Labels:         app=nfs-client-provisioner
                pod-template-hash=6f7bf77fd6
Annotations:    <none>
Status:         Pending
IP:             
IPs:            <none>
Controlled By:  ReplicaSet/nfs-client-provisioner-6f7bf77fd6
Containers:
  nfs-client-provisioner:
    Container ID:   
    Image:          quay.io/external_storage/nfs-client-provisioner:latest
    Image ID:       
    Port:           <none>
    Host Port:      <none>
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Environment:
      PROVISIONER_NAME:  fuseim.pri/ifs
      NFS_SERVER:        192.168.23.60
      NFS_PATH:          /root/NFSDirectory
    Mounts:
      /persistentvolumes from nfs-client-root (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-b7qkh (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             False 
  ContainersReady   False 
  PodScheduled      True 
Volumes:
  nfs-client-root:
    Type:      NFS (an NFS mount that lasts the lifetime of a pod)
    Server:    192.168.23.60
    Path:      /root/NFSDirectory
    ReadOnly:  false
  kube-api-access-b7qkh:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
  Type     Reason       Age               From               Message
  ----     ------       ----              ----               -------
  Normal   Scheduled    23s               default-scheduler  Successfully assigned nfs/nfs-client-provisioner-6f7bf77fd6-fbzhw to node4
  Warning  FailedMount  7s (x6 over 23s)  kubelet            MountVolume.SetUp failed for volume "nfs-client-root" : mount failed: exit status 32
Mounting command: mount
Mounting arguments: -t nfs 192.168.23.60:/root/NFSDirectory /var/lib/kubelet/pods/9d88096e-b189-4510-a4d6-f3ec93585930/volumes/kubernetes.io~nfs/nfs-client-root
Output: mount: wrong fs type, bad option, bad superblock on 192.168.23.60:/root/NFSDirectory,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

解决方案是每个节点执行如下指令:


yum install -y nfs-utils

类似问题在Ubuntu上遇到过,只是报错内容不一样,我是没有想到是nfs-utils工具导致的。

参考资料

  1. 解决nfs挂载错误wrong fs type, bad option, bad superblock