Viewing Persistent Volumes (PV) and Persistent Volume Claims (PVC)
To check details about Persistent Volumes and Persistent Volume Claims, use the following commands:
kubectl get pv kubectl get pvc
Deleting a Persistent Volume Claim (PVC)
Remove a specific Persistent Volume Claim:
kubectl delete pvc <pvc-name>
Deleting a Persistent Volume (PV)
Remove a specific Persistent Volume:
kubectl delete pv <pv-name>
Important Properties to Remember
Defining Volumes in Pod Specification:
##yaml spec: volumes: - name: <volume-name> emptyDir: {}
Mounting Volumes in Container Specification:
##yaml spec: containers: - name: <container-name> volumeMounts: - name: <volume-name> mountPath: <path-in-container>
HostPath Volume:
yaml spec: volumes: - name: <volume-name> hostPath: type: Directory path: <host-path>
Persistent Volume (PV) and Persistent Volume Claim (PVC) Relationship:
PVC remains in a pending state until bound to a PV.
StorageClassName and AccessModes must match between PV and PVC.
Storage size must be within the specified range.
Reclaim Policy for Persistent Volumes
Persistent Volumes have a reclaim policy that dictates their future when the Persistent Volume Claim is deleted:
Recycle: Data in the volume is purged.
Retain: Both data and volume are retained.
Delete: Volume is deleted.
Specifying Reclaim Policy:
yaml spec: persistentVolumeReclaimPolicy: <policy>
PV and PVC Selection
PVs use labels, and PVCs use selectors for PV selection.
PVs are cluster-wide, while PVCs are namespaced.
Explore the world of Persistent Volumes and Claims to provide durable storage for your Kubernetes applications.
Happy Kuberneting!
Top comments (0)