Kubernetes Persistent Volumes and Persistent Volume Claims¶
Persistent Volumes (PV) and Persistent Volume Claims (PVC) are Kubernetes API objects used to manage storage in a cluster.^[400-devops-06-kubernetes-k8s-learning-07pv-pvc-readme.md]
Monitoring and Management¶
Users can inspect the current state of storage resources within the cluster using specific kubectl commands. To list all available Persistent Volumes, the following command is used:^[400-devops-06-kubernetes-k8s-learning-07pv-pvc-readme.md]
[kubectl](<./kubectl.md>) get persistentvolumes
Similarly, to view the status of Persistent Volume Claims—where storage is requested and bound to specific resources—the following command is executed:^[400-devops-06-kubernetes-k8s-learning-07pv-pvc-readme.md]
[kubectl](<./kubectl.md>) get persistentvolumeclaims
Pod Integration¶
A PVC is typically mounted into a specific Pod to provide persistent storage. To verify that a Pod utilizing a PVC is running and to see its node assignment, you can list all Pods across all namespaces:^[400-devops-06-kubernetes-k8s-learning-07pv-pvc-readme.md]
[kubectl get pods](<./kubectl-get-pods.md>) -A -owide
For troubleshooting or direct access, local port forwarding can be established to a specific Pod. For example, to forward local port 8080 to port 80 of a Pod named nginx-pod:^[400-devops-06-kubernetes-k8s-learning-07pv-pvc-readme.md]
[kubectl port-forward](<./kubectl-port-forward.md>) [Pod](<./pod.md>)/nginx-pod 8080:80
Once the tunnel is active, the functionality of the storage can be verified by accessing the application via curl:^[400-devops-06-kubernetes-k8s-learning-07pv-pvc-readme.md]
curl http://localhost:8080
Sources¶
^[400-devops-06-kubernetes-k8s-learning-07pv-pvc-readme.md]