
If you are not familiar with the oc command, refer to OpenShift - Getting Started with the oc command.
A persistent volume (PV) is the "physical" volume (such as a hard disk drive or solid state drive) on the host machine (node) that stores your persistent data, whereas a persistent volume claim (PVC) is a reference to a persistent volume, used by a pod.
Before issuing the oc get pv (Persistent Volumes) command, issue the oc login command. The oc get pv command will return the list of persistent volume.
~]$ oc get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pv001 1Gi RWO Delete Bound project001/pod001 glusterfs-storage 1d
pv002 10Gi RWO Delete Bound project001/pod002 glusterfs-storage 1d
pv003 200Gi RWO Delete Bound project002/pod001 glusterfs-registry-block 123d
Or a single persistent volume claim can be returned.
~]$ oc get pv pv001
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pv001 1Gi RWO Delete Bound project001/pod001 glusterfs-storage 1d
The oc describe pv command can be used to display the details of a Persistent Volume. In this example, the details of the pvc001 Persistent Volume Claim will be displayed.
~]$ oc describe pv pvc-4a4e9b8d-e614-49c1-b1cf-c0a0d8c4a268
Name: pvc-4a4e9b8d-e614-49c1-b1cf-c0a0d8c4a268
Labels: <none>
Annotations: pv.kubernetes.io/provisioned-by: csi.trident.netapp.io
Finalizers: [kubernetes.io/pv-protection external-attacher/csi-trident-netapp-io]
StorageClass: file-storage
Status: Bound
Claim: my-namespace/my-app-v2
Reclaim Policy: Delete
Access Modes: RWO
VolumeMode: Filesystem
Capacity: 1Gi
Node Affinity: <none>
Message:
Source:
Type: CSI (a Container Storage Interface (CSI) volume source)
Driver: csi.trident.netapp.io
FSType:
VolumeHandle: pvc-4a4e9b8d-e614-49c1-b1cf-c0a0d8c4a268
ReadOnly: false
VolumeAttributes: backendUUID=c5d7c284-774d-4c7c-94f4-18d1db9675e2
internalName=k8s_pvc_4a4e9b8d_e614_49c1_b1cf_c0a0d8c4a268
name=pvc-4a4e9b8d-e614-49c1-b1cf-c0a0d8c4a268
protocol=file
storage.kubernetes.io/csiProvisionerIdentity=1626729443511-8081-csi.trident.netapp.io
Events: <none>
Or, the oc get pvc command with the --output json or --output yaml option can be used.
~]$ oc get pv pvc-4a4e9b8d-e614-49c1-b1cf-c0a0d8c4a268 --output json
{
"apiVersion": "v1",
"kind": "PersistentVolume",
"metadata": {
"annotations": {
"pv.kubernetes.io/provisioned-by": "csi.trident.netapp.io"
},
"creationTimestamp": "2021-08-05T18:04:44Z",
"finalizers": [
"kubernetes.io/pv-protection",
"external-attacher/csi-trident-netapp-io"
],
"name": "pvc-4a4e9b8d-e614-49c1-b1cf-c0a0d8c4a268",
"resourceVersion": "22335822",
"uid": "afb728a2-c587-43c3-a47d-7db1dbacba22"
},
"spec": {
"accessModes": [
"ReadWriteOnce"
],
"capacity": {
"storage": "1Gi"
},
"claimRef": {
"apiVersion": "v1",
"kind": "PersistentVolumeClaim",
"name": "redis-storage",
"namespace": "my-namespace",
"resourceVersion": "22335741",
"uid": "4a4e9b8d-e614-49c1-b1cf-c0a0d8c4a268"
},
"csi": {
"driver": "csi.trident.netapp.io",
"volumeAttributes": {
"backendUUID": "c5d7c284-774d-4c7c-94f4-18d1db9675e2",
"internalName": "k8s_pvc_4a4e9b8d_e614_49c1_b1cf_c0a0d8c4a268",
"name": "pvc-4a4e9b8d-e614-49c1-b1cf-c0a0d8c4a268",
"protocol": "file",
"storage.kubernetes.io/csiProvisionerIdentity": "1626729443511-8081-csi.trident.netapp.io"
},
"volumeHandle": "pvc-4a4e9b8d-e614-49c1-b1cf-c0a0d8c4a268"
},
"persistentVolumeReclaimPolicy": "Delete",
"storageClassName": "file-storage",
"volumeMode": "Filesystem"
},
"status": {
"phase": "Bound"
}
}
The --output jsonpath option can be used to print the value of a specific JSON key.
~]$ oc get pv pvc-4a4e9b8d-e614-49c1-b1cf-c0a0d8c4a268 --output jsonpath={.spec.capacity.storage}
1Gi
Did you find this article helpful?
If so, consider buying me a coffee over at