Local Persistent Volume

Step 0: Create a Volume

mkdir -p /mnt/disk/vol1

Give permissions

chmod 777 /mnt/disk/vol1

You should know on which worker node, you want to run your Pod. Based on that you need to run the above commands.

Step 1: Configure StorageClass

kubectl apply -f 01-volume-binding.yaml

This command is not mandatory to run, however if you run this command. always verify your PV and PVC Status.

Step 3: Configure Persistent Volume

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?