Day 36 Task: Managing Persistent Volumes in Your Deployment 💥

Today's tasks:

Task 1:

Add a Persistent Volume to your Deployment todo app.

  • Create a Persistent Volume using a file on your node. Template

  • Create a Persistent Volume Claim that references the Persistent Volume. Template

  • Update your deployment.yml file to include the Persistent Volume Claim. After Applying pv.yml pvc.yml your deployment file look like this Template

  • Apply the updated deployment using the command: kubectl apply -f deployment.yml

  • Verify that the Persistent Volume has been added to your Deployment by checking the status of the Pods and Persistent Volumes in your cluster. Use this commands kubectl get pods ,

kubectl get pv

⚠️ Don't forget: To apply changes or create files in your Kubernetes deployments, each file must be applied separately. ⚠️

solution:

Go To AWS Volumes:

and make sure your Availability Zone is same

create volume

copy this volume id

vol-04190129d0e44251e

kubectl get pv

vim pvc.yml

pvc - persistence volume claim

kubectl apply -f pvc.yml

kubectl get pvc

vim deploymentpvc.yml

kubectl apply -f deploypvc.yml

kubectl get pods

Task 2:

Accessing data in the Persistent Volume,

  • Connect to a Pod in your Deployment using command : `kubectl exec -it -- /bin/bash

  • Verify that you can access the data stored in the Persistent Volume from within the Pod

    kubectl exec -it pvdeploy-f74845446-8n2zc -- /bin/bash

vi testfile

exit

kubectl delete pod pvdeploy-f74845446-8n2zc

kubectl get pods

kubectl exec pvdeploy-f74845446-djzx6 -it -- /bin/bash

cd tmp

ls

Thank you for reading this blog. Hope it helps.

— Safia Khatoon

Happy Learning :)