Deprecated: Just use an NFS PVC, things seem ok. If you find out that there is a real problem (which I doubt), consider writing a CSI driver that does this.
An out of tree, FlexVolume based NFS volume provider for kubernetes.
It mounts NFS volumes onto pods in a more opinionated way than the built in NFS volume. It provides the following guarantees / limitations:
- No NFS export shall be mounted more than once per node
- Integrated
subPath
support
This makes it perform a lot better for cases where a lot of pods are using subPath to mount to various directories in the same NFS export. The in-built volume provider in this case does 1 full NFS mount per pod, which is expensive. Instead, we get away with 1 symlink per pod and 1 NFS mount per node.
You should use this when your pods to nfs exports ratio is in the hundreds or thousands.
-
If this share has not been mounted before with these options, we mount it. We pick a special path to do this to ease housekeeping & testing if this is mounted in the future:
<prefix>/host/<host>/path/<escaped-path>/opts/<sorted-opts>
-
We symlink the subPath required to the mount directory specified by kubelet. This makes the contents available to the pod!
We can also create subPath if it doesn't exist (if
createIfNecessary
is true). -
To unmount, we just unlink the symlink and are done.
-
We should keep track of the number of symlinks pointing to the nfs mount, and unmount it when this gets to 0. This is a TODO item still.