Installation On Microk8s-NFS for Persistent Volumes
Lab Setup:
1. Setup an NFS server
sudo apt-get install nfs-kernel-server
Create a directory to be used for NFS:
sudo mkdir -p /srv/nfs
sudo chown nobody:nogroup /srv/nfs
sudo chmod 0777 /srv/nfs
Make sure that the IP addresses of all your MicroK8s nodes are able to mount this share.
sudo mv /etc/exports /etc/exports.bak
echo '/srv/nfs 192.168.10.0/24(rw,sync,no_subtree_check)' | sudo tee /etc/exports
Restart server.
sudo systemctl restart nfs-kernel-server
2. Install the CSI driver for NFS
microk8s enable helm3
microk8s helm3 repo add csi-driver-nfs https://raw.githubusercontent.com/kubernetes-csi/csi-driver-nfs/master/charts
microk8s helm3 repo update
install the Helm chart under the kube-system
namespace with
microk8s helm3 install csi-driver-nfs csi-driver-nfs/csi-driver-nfs \ --namespace kube-system \ --set kubeletDir=/var/snap/microk8s/common/var/lib/kubelet
CSI controller and node pods to come up
microk8s kubectl --namespace=kube-system get pods -- selector="app.kubernetes.io/instance=csi-driver-nfs" --watch
microk8s kubectl wait pod --selector app.kubernetes.io/name=csi-driver-nfs --for condition=ready --namespace kube-system
Verification CSI Drivers.
microk8s kubectl get csidrivers
3. Create a StorageClass for NFS
Create a Kubernetes Storage Class that uses the nfs.csi.k8s.io CSI driver
microk8s kubectl apply -f sc-nfs.yaml
Persistent Volume Claim Yml.
microk8s kubectl apply -f pvc1.yml
microk8s kubectl get pv
microk8s kubectl get pvc
End Of Lab - Good Luck!