Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubernetes NFS Mount Options

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?

like image 716
Bonn93 Avatar asked Dec 18 '22 20:12

Bonn93


2 Answers

If someone is looking for answers in 2021, here is what is working for me.

  mountOptions:
    - hard
    - timeo=600
    - retrans=3
    - proto=tcp
    - nfsvers=4.2
    - port=2050
    - rsize=4096
    - wsize=4096
    - noacl
    - nocto
    - noatime
    - nodiratime
like image 126
user3702055 Avatar answered Dec 20 '22 10:12

user3702055


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

like image 35
John Blesener Avatar answered Dec 20 '22 10:12

John Blesener