← Back to posts

Building a 3-Node MicroK8s Cluster with NFS Storage


Intro

I wanted a lightweight Kubernetes setup for my homelab, so I tested the MicroK8s cluster creation flow from Portainer.

Reference documentation:

This post summarizes the infrastructure layout I used and how I configured persistent storage using NFS CSI.

Infrastructure Layout

I provisioned Ubuntu 24.04 LTS virtual machines on Proxmox:

RoleHostnameVM IDIP
Control Planemk8s-cp-0120192.0.2.120
Control Planemk8s-cp-1121192.0.2.121
Control Planemk8s-cp-2122192.0.2.122
Storagemk8s-storage-0124192.0.2.124

I used the Proxmox helper script to speed up VM creation:

After provisioning, I had to install and enable SSH manually on the hosts:

sudo apt install -y openssh-server
sudo systemctl enable --now ssh

For high availability, all three Kubernetes nodes were configured as control-plane nodes.

Persistent Storage with NFS CSI

To support persistent volumes, I followed the official MicroK8s NFS documentation:

On the storage VM, I exported an NFS share at /srv/microk8s/data.

I initially set broad permissions during setup to avoid UID/GID mismatches while validating the cluster:

sudo chmod 777 /srv/microk8s/data

For production use, I recommend replacing this with explicit ownership and narrower permissions.

NFS StorageClass

I created the following StorageClass for dynamic provisioning:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: nfs-csi
provisioner: nfs.csi.k8s.io
parameters:
  server: 192.0.2.124
  share: /srv/microk8s/data
reclaimPolicy: Delete
volumeBindingMode: Immediate
mountOptions:
  - hard
  - nfsvers=4.2
← Back to posts