2

when I mount a nas in kubernetes pod, shows this error:

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

and this is my PV config:

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

this pod was on my k8ssalve3 node. when I mount this nas in my k8ssalve3 node host like this:

sudo mount -t nfs -o v3 -wlgf.balabala.extreme.nas.aliyuncs.com:/share /home/miaoyou/nas

I could bind success. This make me confusing. what should I do to fix? any special config with the kubernetes pod? I also mount like this in host machine, works fine:

sudo mount -t nfs -v v3 wlgf.cn-balabala.extreme.nas.aliyuncs.com:/share/k8s/hades-pro/hadesdb/hadesmaster /home/miaoyou/nas

why could not mount on kubernetes pod?

Dolphin
  • 609

1 Answers1

1

I tweak the PVC like this fix it:

  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

move the share path into the path not put in server. Not follow the official document server url.

Dolphin
  • 609