Storage Classes

Kubernetes storage classes define how persistent volumes are provisioned in the K3s cluster.

Available Storage Classes

Storage ClassProvisionerReclaim PolicyDefaultNotes
local-pathrancher.io/local-pathDeleteYes (K3s default)Uses local node storage
longhorndriver.longhorn.ioDeleteNoDistributed replicated storage

local-path (K3s Default)

The K3s default storage class uses the local-path provisioner, which creates PersistentVolumes on the local filesystem of the node where the pod is scheduled.

  • Pros: Simple, fast, no additional infrastructure
  • Cons: No replication, data lost if node fails, pod-to-node affinity required
  • Best for: Non-critical workloads, ephemeral data, development environments
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-pvc
spec:
  storageClassName: local-path
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

Longhorn (Distributed)

Longhorn provides distributed block storage with replication across the three cluster nodes (megatron, thing1, thing2).

  • Pros: Data replication (configurable replicas), snapshots, backups, web UI
  • Cons: Higher resource overhead, network-dependent I/O, more complex
  • Best for: Databases, stateful applications, anything requiring data durability
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-durable-pvc
spec:
  storageClassName: longhorn
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

Quick Commands

# List storage classes
kubectl get storageclass

# List persistent volumes
kubectl get pv

# List persistent volume claims across all namespaces
kubectl get pvc -A

# Check Longhorn volumes
kubectl get volumes.longhorn.io -n longhorn-system

# Check Longhorn replicas
kubectl get replicas.longhorn.io -n longhorn-system

Choosing a Storage Class

Use CaseRecommended ClassReason
Database (production)longhornReplication for durability
Database (dev)local-pathPerformance, simplicity
Container registrylonghornLarge volumes, durability
Temporary build artifactslocal-pathSpeed, disposable
Secrets/configlonghornDurability across restarts

TODO: expand with Longhorn backup configuration, snapshot policies, and volume health monitoring.