π Setting up external NFS storage for kubernetes
Abstract
How to provision NFS storage from a NAS, to a K3S cluster.
Prerequisites
- K3S cluster
- A NAS that has an NFS share configured with the correct export rules.
1. CSI driver NFS
https://github.com/kubernetes-csi/csi-driver-nfs
Install the NFS binaries on your nodes. I'm running Ubuntu:
helm repo add csi-driver-nfs https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/charts
The below command installs the current latest version 4.12.0 Please consult the github page of csi-driver-nfs for the latest version.
helm install csi-driver-nfs csi-driver-nfs/csi-driver-nfs --namespace kube-system --version 4.12.0 --set externalSnapshotter.enabled=true --set controller.runOnControlPlane=true --set controller.replicas=2
Check if the pod is running:
2. Storage class
Now create a storage class:
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: nfs-csi
provisioner: nfs.csi.k8s.io
parameters:
server: 192.168.10.90
share: /mnt/user/k3s
reclaimPolicy: Delete
volumeBindingMode: Immediate
allowVolumeExpansion: true
mountOptions:
- nfsvers=4.1
Save it locally on your workstation. I'll save mine in C:\Users\cedric.kube\nfs-csi
Now apply it: