Use NFS for Persistent Volumes on MicroK8s

Hi

Thanks for this article.

I found it, and the discussion very helpful in my troubleshooting efforts, specifically the posts regarding dynamic provisioning vs static nfs pvc.

I am posting this comment in the hope that it may assist others.

With static provisioning, I am getting an error regarding the /var/snap/ directory being read only:

Warning  FailedMount  3m32s (x448 over 14h)  kubelet  MountVolume.SetUp failed for volume "pvc-1c0b7728-5ebd-4bb0-85ba-0f0877ab9080" : rpc error: code = Internal desc = mkdir /var/snap: read-only file system

I see from the driver source https://github.com/kubernetes-csi/csi-driver-nfs/blob/master/charts/latest/csi-driver-nfs/templates/csi-nfs-node.yaml that the kubeletDir/pods, kubeletDir/plugins/csi-nfsplugin and kubeletDir/plugins_registry objects are referenced, but all only accessible by root.

On the other hand, I did not experience this with dynamic provisioning.

A couple of other comments I can make based on what I have found during troubleshooting:

  • I know this may be nfs server specific, but I found (man 5 exports on ubuntu 22.04) that sync and no_subtree_check are both defaults, so in my case I can remove redundant options in the /etc/exports entry
  • My installation of microk8s (–channel=1.28/stable --classic) placed a symbolic link at /var/lib/kubelet to /var/snap/microk8s/common/var/lib/kubelet, making (in my case) the overriding of kubeletDir redundant.
    Neither of these would be expected to cause a problem, but simplification is possible.

Thanks again

Kind Regards
Martin

1 Like