Local Persistent Volume
Step 0: Create a Volume
mkdir -p /mnt/disk/vol1
Give permissions
chmod 777 /mnt/disk/vol1
Step 1: Configure StorageClass
kubectl apply -f 01-volume-binding.yaml
Step 3: Configure Persistent Volume
You need to change the nodeSelectorTerms value to your own worker node name in the 02-lpv.yaml file. Use the worker node name on which you have created the vol1 folder in step 0
kubectl apply -f 02-lpv.yaml
Step 4: Configure Persistent Volume Claim
kubectl apply -f 03-lpvc.yaml
Step 5: Persistent volume claim is not bound to the persistent volume automatically. Instead, it will remain "Available" until the first consumer shows up
kubectl get pv
Step 6: Deploy the Application
kubectl create -f 04-app.yaml
kubectl get pv
kubectl get pods
echo "Hello local persistent volume" > /mnt/disk/vol1/index.html
kubectl delete pod www
Look at PV status is still "Bound", even though the POD is gone.
Scenario 1
kubectl apply -f 05-newpod.yaml
kubectl logs centos-local-volume
Scenario 2
Verifying Multiple Read Access
kubectl apply -f 06-newpod-multiread.yaml
kubectl logs centos-local-volume2
Clear Everything in the current namespace
kubectl delete all --all -n default
kubectl delete pvc --all
kubectl delete pv --all
Run the Below command on those Nodes, where you have created the mount path.
If you are not aware then run this below command on all the nodes.
sudo rm -rf /mnt/disk
Last updated
Was this helpful?