KevsRobots Learning Platform
50% Percent Complete
By Kevin McAleer, 3 Minutes
Page last updated May 24, 2025

In Kubernetes, storage isnβt tied to a container like in Docker β itβs managed independently as persistent volumes (PVs) and persistent volume claims (PVCs).
This lesson will show you how storage works in K3s, how to use the built-in local-path provisioner, and how to prepare for external storage options (like NFS or USB SSDs).
K3s includes a default dynamic storage provisioner called local-path-provisioner.
β οΈ If a pod moves to a different node, its data may not follow.
Create a file pvc-demo.yaml:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: demo-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
Apply it:
kubectl apply -f pvc-demo.yaml
Create a pod with a volume mount:
apiVersion: v1
kind: Pod
metadata:
name: pvc-tester
spec:
containers:
- name: busybox
image: busybox
command: [ "sleep", "3600" ]
volumeMounts:
- mountPath: "/data"
name: myvolume
volumes:
- name: myvolume
persistentVolumeClaim:
claimName: demo-pvc
Apply it:
kubectl apply -f pvc-tester.yaml
Then exec into the pod and test:
kubectl exec -it pvc-tester -- sh
# Inside pod:
echo "Hello Pi Cluster" > /data/test.txt
cat /data/test.txt
On the node hosting the pod, the data is typically under:
/opt/local-path-provisioner
Each PVC is stored in its own directory.
For more advanced setups:
| Option | Benefit | Tool |
|---|---|---|
| USB SSD | Fast, local storage | Mount manually or with Longhorn |
| NFS Server | Shared across all nodes | Use nfs-subdir-external-provisioner |
| Ceph | Highly available block storage | More complex to set up |
π Consider using Longhorn if you want persistent block storage with replication and snapshots.
To remove test volumes and pods:
kubectl delete pod pvc-tester
kubectl delete pvc demo-pvc
You now know how to:
Next up: Ingress and Services
You can use the arrows β β on your keyboard to navigate between lessons.
Comments