Table of Contents

The following is a step by step guide to install and setup Kubernetes with Network Storage on your own hardware.

1. Install MicroK8s

Install a lightweight Kubernetes distribution:

sudo snap install microk8s --classic

Check the installation status and wait for the Kubernetes services to initialize:

microk8s status --wait-ready

2. Enable Required Add-ons in MicroK8s

List available and installed add-ons:

microk8s status

Enable necessary add-ons (replace [add-on name] with dns, hostpath-storage, ingress, or metallb):

microk8s enable [add-on name]

3. Configure MetalLB

Enable MetalLB:

microk8s enable metallb

Provide an IP range for the load balancer when prompted for example:

10.244.0.1-10.244.0.10

4. Install NFS CSI Driver

Add the NFS CSI driver Helm chart repository:

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 for the NFS CSI driver:

microk8s helm3 install csi-driver-nfs csi-driver-nfs/csi-driver-nfs --namespace kube-system

Wait for the NFS CSI driver pods to be ready:

microk8s kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=csi-driver-nfs --namespace kube-system

5. Create and Apply NFS Storage Class

Create a storageclass.yaml file with the following content:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: nfs-csi
provisioner: nfs.csi.k8s.io
parameters:
  server: <NFS_SERVER_IP>
  share: <NFS_EXPORT_PATH>
reclaimPolicy: Delete
mountOptions:
  - hard
  - nfsvers=4.1

Replace <NFS_SERVER_IP> and <NFS_EXPORT_PATH> with the actual server IP and export path.

Apply the StorageClass configuration:

microk8s kubectl apply -f storageclass.yaml

This will install Kubernetes and all the necessary configuration required for your cluster. Now the cluster is ready for any application you want to install and run on it.