How can I set port for NFS volume?

Cluster information:

Kubernetes version: 1.23.1
Cloud being used: bare-metal (Raspberry pi)
Installation method: kubeadm
Host OS: Ubuntu arm64
CNI and version: containerd
CRI and version: calico

How can I set port for NFS volume?

I have NFS server on port 30000(TCP). I want to make auto provisioning system with the NFS server, so I applied provisioner deployment:

kind: Deployment
apiVersion: apps/v1
metadata:
  name: nfs-provisioner
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nfs-provisioner
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: nfs-provisioner
    spec:
      serviceAccountName: nfs-provisioner-sa
      containers:
        - name: nfs-provisioner
          image: k8s.gcr.io/sig-storage/nfs-subdir-external-provisioner:v4.0.2
          volumeMounts:
            - name: nfs-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: k8s-sigs.io/nfs-subdir-external-provisioner
            - name: NFS_SERVER
              value: "192.168.0.7:30000"
            - name: NFS_PATH
              value: /provision/
      volumes:
        - name: nfs-root
          nfs:
            server: "192.168.0.7:30000"
            path: /provision/

But it is not works and pod has next description.

Events:
  Type     Reason       Age                      From     Message
  ----     ------       ----                     ----     -------
  Warning  FailedMount  15m (x79 over 3h55m)     kubelet  Unable to attach or mount volumes: unmounted volumes=[nfs-root], unattached volumes=[nfs-root kube-api-access-xfkcn]: timed out waiting for the condition
  Warning  FailedMount  7m31s (x121 over 3h57m)  kubelet  MountVolume.SetUp failed for volume "nfs-root" : mount failed: exit status 32
Mounting command: mount
Mounting arguments: -t nfs 192.168.0.7:30000:/provision/ /var/lib/kubelet/pods/a953d08c-9c9a-44f0-848d-0d4e1d500ae7/volumes/kubernetes.io~nfs/nfs-root
Output: mount.nfs: requested NFS version or transport protocol is not supported
  Warning  FailedMount  2m13s (x20 over 3h39m)  kubelet  Unable to attach or mount volumes: unmounted volumes=[nfs-root], unattached volumes=[kube-api-access-xfkcn nfs-root]: timed out waiting for the condition

I found that kubernetes uses wrong command args, -t nfs 192.168.0.7:30000:/provision/ instead of -o port=30000 -t nfs 192.168.0.7:/provision/. So I have looked for API Reference about NFS to know how can I set port for NFS server, but there is no ‘port’ option.

How can I set port for NFS volume?

1 Like
apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs-vol
spec:
  storageClassName: nfs
  accessModes:
  - ReadWriteMany
  capacity:
    storage: 1Gi
  persistentVolumeReclaimPolicy: Retain
  mountOptions: # https://www.commandlinux.com/man-page/man5/nfs.5.html
  - port=30000
  nfs:
    path: /provision
    server: 192.168.0.7
    readOnly: false

deployment:

...
      volumes:
      - name: nfs-root
        persistentVolumeClaim:
          claimName: nfs-vol