Kubernetes NFS Mount Options

10/2/2018

I've recently started using NFS volumes for my clusters on-prem. This is the simplest and best solution for me, however it seems pretty limited in regards to the actual mounts options.

Is there anyway to set mount options on the node/cluster in the volume.yml files?

  • NFSv3
  • NFSv4/4.1
  • lookupcache
  • noatime
  • rsize,wsize

I have application that requires a specific version and also these mount options for performance.

apiVersion: v1
kind: PersistentVolume
metadata:
  name: nfs
spec:
  capacity:
    storage: 1Mi
  accessModes:
    - ReadWriteMany
  nfs:
    # FIXME: use the right IP
    server: 10.244.1.4
    path: "/"

Is there anyway to add mount flags here?

-- Bonn93
kubernetes
nfs
performance
persistent-volumes

2 Answers

1/17/2020

It is possible and it's been GA in Kubernetes since 1.8.

apiVersion: v1
kind: PersistentVolume
metadata:
  name: pv0003
spec:
  capacity:
    storage: 5Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Recycle
  storageClassName: slow
  mountOptions:
    - hard
    - nfsvers=4.1
  nfs:
    path: /tmp
    server: 172.17.0.2

https://kubernetes.io/docs/concepts/storage/persistent-volumes/#mount-options

https://github.com/kubernetes/enhancements/issues/168#issuecomment-317748159

-- John Blesener
Source: StackOverflow

10/3/2018

Not really. Not supported by Kubernetes yet.

If you really need very specific NFS options, for now, I would recommend using hostPath.

This way you can mount your NFS volumes on a specific mount point on your host and have your Kubernetes pods use that.

-- Rico
Source: StackOverflow