Kubernetes

輸出:以單位 run-2863.scope 執行範圍。mount.nfs:掛載時伺服器拒絕訪問

  • May 20, 2021

當我在 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

這是我的 PV 配置:

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 節點上。當我像這樣在我的 k8ssalve3 節點主機中安裝這個 nas 時:

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 上?

我像這樣調整 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。

引用自:https://unix.stackexchange.com/questions/650507