我正在尝试将NFS装载到我的Kubernetes pod中。
我正在本地机器上使用Minikube&曾经有一个hostPath卷,但它的性能很差(页面加载大约需要30秒或更长时间(
我在Mac上设置了NFS服务器,如下所示:
echo "/Users/my-name/share-folder -alldirs -mapall="$(id -u)":"$(id -g)" $(minikube ip)" | sudo tee -a /etc/exports && sudo nfsd restart
并用进行验证
showmount -e
这显示:
Exports list on localhost:
/Users/my-name/share-folder 192.168.xx.x
我已经设置/应用了如下的persistentVolume:
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'
我已经设置/应用了如下的persistentVolumeClaim:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: sources-volume-claim
namespace: default
spec:
storageClassName: standard
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
我可以看到持续的音量&persistentVolumeClaim在我的Kubernetes面板中。它甚至说persistentVolumeClaim是绑定的,然而。。。
当我通过kubectl命令应用更新的deployment.yaml文件时,我一直看到错误:
卷"default sources volume"的MountVolume.SetUp失败:mount失败:exit status 32装载命令:systemd run装载参数:--description=/var/lib/kubelet/pods/f4b26fe1-957-11e8-8f3d-e61688dc52f9/volumes/Kubernetes.io~nfs/default sources volume--scope--mount-t nfs 192.168.xx.x:/Users/my name/share文件夹的Kubernetes临时装载/var/lib/kubelet/pods/f4b26fe1-9565-11e8-8f3d-e61688dc52f9/volumes/kubernetes.io~nfs/default-sources-volume输出:以单元形式运行作用域:run-r1b76b36ffcb1409284e308b11c729744.scope mount.nfs:装载192.168.xx.x:/Users/my name/share folder 时服务器拒绝访问
请在"/etc/exports"中尝试此操作/Users/my-name/share-folder *(rw,fsid=0,async,no_subtree_check,no_auth_nlm,insecure,no_root_squash)
和sudo exportfs -a
我发现insecure
是关键。