背景:今天遇到一个问题,容器挂载nfs报错,报错内容为:
Events:
Type Reason Age From Message
Warning FailedMount 5m (x36 over lh) kubelet, 172.16.2.7 (combined from similar events): MountVolume.Setup failed for volume "runtime" : mount failed: exit status 32
Mounting command: systemd-run
Mounting arguments: --description=Kubernetes transient mount for /var/lib/kubelet/pods/8b986f57-ff44-lle8-93d9-Oa587f800f51/voluines/kubernetes.io-nfs/runtime --scope -- mount -t nfs 172.16.3.6:/tspms/ts-development/
runtime /var/lib/kubelet/pods/8b986f57-ff44-lle8-93d9-Oa587f800f51/voluines/kubernetes.io-nfs/runtime
Output; Running scope as unit run-r6921855d6e6943fea742c4397f65d90e.scope._______________________________
mount.nfs: access denied by server while mounting 172.16.3.6:/tspms/ts-development/runtime
—Warning—FailedMount—12s (x36 over lh)—kubelet, 172.16.2.7—Unable to mount volumes for pod "tspms-5c97cb47bc-jzhkd_ts-development(8b986f57-ff44-lle8-93d9-Oa587f800f51)": timeout expired waiting for volumes to a
ttach or mount for pod "ts-development'7"tspms-5c97cb47bc-jzhkd".list of unmounted volumes=[runtimeJ.list of unattached volumes=[runtime default-token-wfhg7)
由于之前有过历史的问题是 nfs v3 v4挂载出现了问题,k8s默认的是 v4格式挂载,nfs建议是使用v3格式挂载。
我登录上节点直接挂载,发现也是同样的报错,于是从nfs挂载命令格式下手
root@VM-1-6-ubuntu:/# mount -t nfs -o vers=3 172.16.3.6:/tspms/ts-development/runtime /testnfs
mount.nfs: access denied by server while mounting 172.16.3.6:/tspms/ts-development/runtime
之前有询问过得出的nfs 挂载格式:
v4:
mount -t nfs4 vip:/ /localdir
v3:
mount -t nfs -o vers=3 vip:/fsid /localdir
于是乎突发奇想
对照了v3的格式我改成如下的挂载路径,就发现挂载成功了,如果用v3的方法直接挂载不加fsid,也是会access denied。
总结来说 用v3挂载一定要加上fsid
,在本文中对应为8pw2jq8u
,具体的还得参照你cfs
中对应的fsid
mount -t nfs 172.16.3.6:/8pw2jq8u/tspms/ts-development/runtime
那么要解决真正的问题,把服务启动正常,把yaml文件中volume的path调整为含有fsid的格式。
在yaml文件的体现为:
volumes:
- name: runtime
nfs:
path: /8pw2jq8u/tspms/ts-development/runtime
server: 172.16.3.6
最后总结一点,在控制台中应该如何展示呢?其实还是一样的,在nfs ip后面加上fsid即可,fsid在cfs界面中获取。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。