当我在 kubernetes pod 中安装 nas 时,显示此错误:
MountVolume.SetUp failed for volume "nfs-hades-mysql-pv1" : mount failed: exit status 32 Mounting command: systemd-run Mounting arguments: --description=Kubernetes transient mount for /var/lib/kubelet/pods/19995168-e921-4b1e-abbd-01df68518f85/volumes/kubernetes.io~nfs/nfs-hades-mysql-pv1 --scope -- mount -t nfs -o nfsvers=3,noresvport 12d025e2-wlgf.cn-balabala.extreme.nas.aliyuncs.com:/share:/k8s/hades-pro/hadesdb/hadesmaster /var/lib/kubelet/pods/19995168-e921-4b1e-abbd-01df68518f85/volumes/kubernetes.io~nfs/nfs-hades-mysql-pv1 Output: Running scope as unit run-2863.scope. mount.nfs: access denied by server while mounting wlgf.balabala.extreme.nas.aliyuncs.com:/share:/k8s/hades-pro/hadesdb/hadesmaster
这是我的光伏配置:
kind: PersistentVolume
apiVersion: v1
metadata:
name: nfs-hades-mysql-pv1
selfLink: /api/v1/persistentvolumes/nfs-hades-mysql-pv1
uid: 71a4f185-b5a9-45c8-bd93-8a8e80ff1f0f
resourceVersion: '64010004'
creationTimestamp: '2021-05-19T10:46:03Z'
labels:
alicloud-pvname: hades-mysql-data-db
finalizers:
- kubernetes.io/pv-protection
spec:
capacity:
storage: 10Gi
nfs:
server: 'wlgf.balabala.extreme.nas.aliyuncs.com:/share'
path: /k8s/hades-pro/hadesdb/hadesmaster
accessModes:
- ReadWriteOnce
claimRef:
kind: PersistentVolumeClaim
namespace: hades-pro
name: data-hades-mysql-ha-mysqlha-0
uid: 7b9256df-5c82-4285-8157-de8468449bcf
apiVersion: v1
resourceVersion: '63882330'
persistentVolumeReclaimPolicy: Retain
mountOptions:
- nfsvers=3
- noresvport
volumeMode: Filesystem
status:
phase: Bound
这个 Pod 位于我的 k8ssalve3 节点上。当我将这个 nas 安装在我的 k8ssalve3 节点主机中时,如下所示:
sudo mount -t nfs -o v3 -wlgf.balabala.extreme.nas.aliyuncs.com:/share /home/miaoyou/nas
我可以绑定成功。这让我很困惑。我应该做什么来修复? kubernetes pod 有什么特殊配置吗?我也在主机中像这样安装,工作正常:
sudo mount -t nfs -v v3 wlgf.cn-balabala.extreme.nas.aliyuncs.com:/share/k8s/hades-pro/hadesdb/hadesmaster /home/miaoyou/nas
为什么无法挂载到 kubernetes pod 上?
答案1
我像这样调整 PVC 修复它:
kind: PersistentVolume
apiVersion: v1
metadata:
name: nfs-hades-mysql-pv1
selfLink: /api/v1/persistentvolumes/nfs-hades-mysql-pv1
uid: 71a4f185-b5a9-45c8-bd93-8a8e80ff1f0f
resourceVersion: '64010004'
creationTimestamp: '2021-05-19T10:46:03Z'
labels:
alicloud-pvname: hades-mysql-data-db
finalizers:
- kubernetes.io/pv-protection
spec:
capacity:
storage: 10Gi
nfs:
server: 'wlgf.balabala.extreme.nas.aliyuncs.com'
path: /share/k8s/hades-pro/hadesdb/hadesmaster
accessModes:
- ReadWriteOnce
claimRef:
kind: PersistentVolumeClaim
namespace: hades-pro
name: data-hades-mysql-ha-mysqlha-0
uid: 7b9256df-5c82-4285-8157-de8468449bcf
apiVersion: v1
resourceVersion: '63882330'
persistentVolumeReclaimPolicy: Retain
mountOptions:
- nfsvers=3
- noresvport
volumeMode: Filesystem
status:
phase: Bound
将路径移动share
到服务器中未放置的路径中。不遵循官方文档服务器 url。