
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.
The oc get pvc command will return the list of persistent volume claims. Access Modes can be one or more of the following:
- ReadWriteOnce (RWO) - The volume may only be mounted on a single node
- ReadWriteOncePod (RWOP) - The volume may only be mounted on a single pod
- ReadOnlyMany (ROX) - The volume may be mounted on different nodes
- ReadWriteMany (RWX) - The volume can be mounted on different nodes
~]$ oc get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
my-pvc-1 Bound pvc-385996a0-70af-4791-aa8e-9e6459e6b123 1Gi RWO file-storage 659d
my-pvc-2 Bound pvc-8aeddd4d-aad5-4039-8d04-640a71c9a72d 10Gi RWO file-storage 659d
my-pvc-3 Bound pvc-0050144d-940c-4c4e-a23a-2a660a5490eb 10Gi RWO file-storage 659d
The oc describe pvc command can be used to display the details of a Persistent Volume Claim. In this example, the details of the pvc001 Persistent Volume Claim will be displayed. Notice in this example that the Persistent Volume Claim is being used by the pod "my-app-2mp2k".
~]$ oc describe pvc my-pvc-1
Name: my-pvc-1
Namespace: foo
StorageClass: file-storage
Status: Bound
Volume: pvc-2db07c57-e282-48e7-bfb1-4cbd7245c25e
Labels: <none>
Annotations: pv.kubernetes.io/bind-completed: yes
pv.kubernetes.io/bound-by-controller: yes
volume.beta.kubernetes.io/storage-provisioner: csi.trident.netapp.io
Finalizers: [kubernetes.io/pvc-protection]
Capacity: 1Gi
Access Modes: RWO
VolumeMode: Filesystem
Used By: my-app-2mp2k
The oc describe pod command can be used to see that the Persistent Volume Claim is mounted to the /var/data directory in the container.
~]$ oc describe pod my-app-2mp2k
Containers:
my-container:
Mounts:
/var/data from my-pvc-1 (rw)
The oc exec and df command can be used to get the amount of storage being used by the /var/data mount in the container.
~]$ oc exec pod/my-app-2mp2k -- df
Filesystem 1K-blocks Used Available Use% Mounted on
overlay 125277164 46024772 79252392 37% /
tmpfs 65536 0 65536 0% /dev
tmpfs 12333448 0 12333448 0% /sys/fs/cgroup
shm 65536 0 65536 0% /dev/shm
tmpfs 12333448 63876 12269572 1% /etc/hostname
10.84.234.142:/trident_qtree_pool_k8s_LDKEDEQUWG/k8s_pvc-2db07c57-e282-48e7-bfb1-4cbd7245c25e 125277164 46024772 79252392 37% /var/data
tmpfs 12333448 32 12333416 1% /run/secrets/kubernetes.io/serviceaccount
tmpfs 12333448 0 12333448 0% /proc/acpi
tmpfs 12333448 0 12333448 0% /proc/scsi
tmpfs 12333448 0 12333448 0% /sys/firmware
Did you find this article helpful?
If so, consider buying me a coffee over at