// docs / Kubernetes / Longhorn

Longhorn

Next, I'm going to install Longhorn for persistent storage across the cluster. It automatically handles:

  • Volume provisioning and scheduling
  • Replication across nodes for high availability
  • Snapshots and backups

This allows stateful apps like databases, Git servers and monitoring tools to run reliably inside K3s with minimal manual management.


# Add Longhorn to Helm
helm repo add longhorn https://charts.longhorn.io
helm repo update

# Deploy longhorn and create the namespace
helm install longhorn longhorn/longhorn --namespace longhorn-system --create-namespace

# Check the storageclass exists
kubectl get storageclass

# Remove the local-path as the default storage class
kubectl patch storageclass local-path -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'

# Temporarily port forward from the pod
# Connect to http://localhost:8080
kubectl port-forward -n longhorn-system pod/longhorn-ui-8666455ff7-s2n2h 8080:8000

The frontend shows the current fresh storage, with 30GB reserved per node for the sake of additional applications, downloads, files etc.