Configure Persistent Storage for K3s
Intermediatev1.0.0
Set up persistent storage in K3s clusters using local-path-provisioner, Longhorn distributed storage, and NFS for stateful workloads like databases and file stores.
Content
Overview
K3s bundles local-path-provisioner by default for single-node storage. For production multi-node clusters, you need distributed storage like Longhorn or external NFS to ensure data availability when pods move between nodes.
Why This Matters
- -Stateful workloads — databases, message queues, and file stores need persistent data
- -Pod mobility — distributed storage lets pods run on any node
- -Data protection — replication prevents data loss from node failure
- -Dynamic provisioning — create PVCs on demand without manual PV creation
How It Works
Option A: Local-Path (Default — Single Node)
Option B: Longhorn (Distributed — Multi Node)
Option C: NFS External Storage
Best Practices
- -Use local-path only for single-node or development clusters
- -Use Longhorn for multi-node production (built-in replication and backups)
- -Set
reclaimPolicy: Retainfor production data (prevents accidental deletion) - -Configure Longhorn replica count to match your node count (max 3)
- -Set resource limits on Longhorn manager to prevent resource starvation
- -Test storage failover by draining nodes and verifying data access
Common Mistakes
- -Using local-path on multi-node clusters (data stuck on one node)
- -Not installing open-iscsi before Longhorn (volumes fail to attach)
- -Setting replica count higher than node count (volumes stay degraded)
- -Using
reclaimPolicy: Deletefor production databases - -Not monitoring storage capacity (PVCs fail when disk is full)
FAQ
Discussion
Loading comments...