By Kevin McAleer, 5 Minutes
Page last updated November 24, 2026

By the end of this lesson you will be able to give a pod storage that survives restarts by using a PersistentVolumeClaim with K3s’s built-in local-path storage, and explain its limits.
Anything a container writes to its own filesystem disappears when the pod is replaced. That is fine for nginx, but not for a database or a counter you want to keep. Kubernetes separates the request for storage from the storage itself:
K3s ships a StorageClass called local-path, which is the default. When you create a PVC, it makes a folder on a node’s disk and hands it over. Check it exists:
kubectl get storageclass
flowchart LR
P["Pod"] -->|"mounts"| C["PVC demo-pvc<br/>your request"]
C -->|"bound to"| V["PV<br/>made automatically"]
V --> D["Folder under<br/>/var/lib/rancher/k3s/storage<br/>on one node"]
SC["StorageClass local-path"] -.->|"creates"| V
Create pvc-demo.yaml:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: demo-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-path
resources:
requests:
storage: 1Gi
kubectl apply -f pvc-demo.yaml
kubectl get pvc
The PVC will probably show Pending. That is expected: local-path waits until a pod actually uses the claim, so that it can create the folder on the same node the pod runs on.
Create pvc-tester.yaml:
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
kubectl apply -f pvc-tester.yaml
kubectl get pvc
Once the pod is running, the PVC changes to Bound. Write a file, then delete and recreate the pod:
kubectl exec pvc-tester -- sh -c 'echo "Hello Pi cluster" > /data/test.txt'
kubectl delete pod pvc-tester
kubectl apply -f pvc-tester.yaml
kubectl exec pvc-tester -- cat /data/test.txt
The file is still there, because it lives in the volume, not in the pod.
By default local-path stores data on the node’s disk under /var/lib/rancher/k3s/storage. Find which node your pod ran on with kubectl get pod pvc-tester -o wide, then on that Pi:
sudo ls /var/lib/rancher/k3s/storage
You will see a folder named after the volume. You can change this location with the default-local-storage-path setting in /etc/rancher/k3s/config.yaml.
For storage that follows pods around, look at Longhorn, which the K3s docs list as a distributed block storage option (it is not supported on 32-bit ARM, which is another reason to use 64-bit), or an NFS share on a NAS.
Teachers: Storage is where learners lose work. Make the point early that data in local-path is not backed up, and that deleting a PVC deletes the data. If many learners share a cluster, a small SSD can fill up, so agree a size (
1Giis plenty) and clean up claims at the end of a session.
kubectl delete pod pvc-tester
kubectl delete pvc demo-pvc
kubectl get pv. What is the name of the volume and its status?2Gi in a new file, apply it, and see what you get.test.txt directly from the node’s disk.Pending.kubectl describe pvc demo-pvc and read the Events.Why: local-path waits for the first pod to use the claim before choosing a node.
Quick quiz 1 of 3
What is the name of the default StorageClass in K3s?
Quick quiz 2 of 3
Where does local-path store data by default?
Quick quiz 3 of 3
What is a PVC?
Comments