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
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: ext4Replication 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
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/testRules 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.