StorageClass: local-path provider(EN)

Albert Weng
2 min readSep 21, 2023


Today, I will provide a brief demonstration on how to utilize the local-path provider within a Kubernetes cluster to establish a storage class for the purpose of facilitating data storage for applications.

The path “/opt/local-path-provisioner” on each node is designated for data storage, and it is installed by default in the “local-path-storage” namespace.

This approach is recommended for testing purposes based on personal experience. In production, it is advisable to utilize the Container Storage Interface (CSI) provided by storage vendors to connect to external storage solution.

Let’s get started!

1. Deploy provider

# wget
# kubectl create -f local-path-storage.yaml
# kubectl get all -n local-path-storage

2. Deploy app

# wget
# wget
# kubectl create -f pvc.yaml
# kubectl create -f pod.yaml

# kubectl get pvc
# kubectl get pod
// Write data
# kubectl exec volume-test -- sh -c "echo local-path-test > /data/test"
# kubectl delete -f pod.yaml
# kubectl create -f pod.yaml (recreate)
# kubectl exec volume-test -- sh -c "cat /data/test"
local-path-test (still exist)

The above is the simplest approach. Later, we will analyze the differences between the two methods: local volume and hostpath.



Albert Weng

You don't have to be great to start, but you have to start to be great