HostPath Volume

Step 1: Verify the volume folder is available on all the nodes of Kubernetes Cluster

ls /mnt/data/vol

Step 2: Create a Persistent Volume

kubectl create -f 01-Persistent-Volume.yaml

Step 3: Verify the Volumes

kubectl get pv

Step 4: Show more details about the Volume

kubectl get pv vol-x -o yaml

Step 5: Create Persistent Volume

kubectl apply -f 02-Persistent-Volume-Claim.yaml

Step 6: Verify the PVC Status

kubectl get pvc

Step 7: Describe and Verify the PVC

kubectl describe pvc http-claim

Step 8: Create and Run the application pod

kubectl apply -f 03-app.yaml

Step 9: Now try to access the pod and see the application

  • See on which Worker Node the pod is scheduled

  • If the Pod is Scheduled on Worker1, then login to the specific worker node and perform below steps

Step 9: Add data to the Volume

Give permissions

Access the Pod IP using CURL and check the output

Sample CURL Statement : curl http://nodeip

Step 11: Now Lets change the Value, by being inside the container

Access the Pod IP using CURL and check the output

Sample CURL Statement : curl http://nodeip

Step 12: Lets Delete the Pod and see weather data persists or not

Step 13: Check PVC

Step 14: Create a new pod with older Volume

Step 15: Verify weather we are able to read the index.html using the new pod

See on which Worker Node Centos Pod is scheduled and then accordingly run the commands

Clear Everything in the current namespace

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.

Last updated

Was this helpful?