Choosing Storage for a Small Kubernetes Cluster

Comparing local volumes, NFS, Longhorn and Ceph for small clusters, with the failure behaviour of each.

Published Apr 14, 202610 min read5 views
  • homelab
  • kubernetes
  • linux
  • storage

Start from the failure you can tolerate

Option

Survives node loss

Complexity

Good for

hostPath / local PV

No

Very low

Caches, rebuildable data

NFS

Yes, if the server survives

Low

Shared read-mostly data

Longhorn

Yes (replicas)

Medium

Small clusters, RWO volumes

Ceph / Rook

Yes

High

Larger clusters, RWX and object

A StorageClass with sane defaults

YAML
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: longhorn-r2
provisioner: driver.longhorn.io
allowVolumeExpansion: true
reclaimPolicy: Retain
volumeBindingMode: WaitForFirstConsumer
parameters:
  numberOfReplicas: "2"
  staleReplicaTimeout: "30"
  fsType: ext4

Replication is not backup

Replicated block storage protects against a node failing. It faithfully replicates a DROP TABLE too. Take application-level backups to a different failure domain and test the restore.

Performance expectations

Bash
kubectl run fio --rm -it --image=ljishen/fio --restart=Never -- \
  fio --name=randrw --ioengine=libaio --direct=1 --bs=4k --iodepth=32 \
      --rw=randrw --rwmixread=70 --size=2G --runtime=60 --filename=/data/test

Rules that keep it boring

  • Never run replicated storage on consumer SSDs without power-loss protection for databases.

  • Keep the storage network separate from the workload network where you can.

  • Alert on degraded replica counts, not only on volume-down.

Back to all docs