What are Persistent Volumes in k8s
In Kubernetes, a Persistent Volume (PV) is a piece of storage in the cluster that has been provisioned by an administrator. A Persistent Volume Claim (PVC) is a request for storage by a user. The PVC references the PV, and the PV is bound to a specific node. Read official documentation of Persistent Volumes.
Step 1: Create a Persistent Volume (PV)
Apply the PV to your cluster
kubectl apply -f pv.yml
Step 2: Create a Persistent Volume Claim (PVC)
Apply the PVC to your cluster
kubectl apply -f pvc.yml
Step 3: Update your Deployment YAML
Step 4: Apply the Updated Deployment
kubectl apply -f deployment.yml
Step 5: Verify the Persistent Volume
kubectl get pv
Step 6: To verify that the PVC is bound to the PV and that your Deployment is using it, you can check the status of Pods
kubectl get pods
Step 1: Get the name of one of your Pods
kubectl get pods -n <namespace-name>
Step 2: Access a Pod with a Shell
kubectl exec -it <pod-name> -- /bin/bash
Step 3: Access the Persistent Volume data
Thank you so much for reading
Follow me on LinkedIn to see interesting posts like this : )