Skip to content

Openshift - Volumes

Commands

Storage Class

List storage class:

oc get sc

Persistent Volume (PV)

List all PV:

oc get pv

PV Detail:

oc describe pv {pv_name}
oc get pvc {pv_name} -o yaml

Force PV deletion:

oc delete pv {pv-name} --grace-period=0 --force
oc patch pv {pv-name} -p '{"metadata": {"finalizers": null}}'

Persistent Volume Claim (PVC)

List all PVC:

oc get pvc (--all-namespaces)

PVC Detail:

oc describe pvc {pvc_name}
oc get pvc {pvc_name} -o yaml

Manifests

Persistent Volume Claim (PVC)

See an example of PVC manifest:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: ceph-pvc-1
  namespace: my-ns
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  storageClassName: sc-ceph-rbd

Procedures

Resize PVC

Edit PVC:

oc edit pvc data-myapp

Edit spec/resources/requests/storage with new value:

spec:
  resources:
    requests:
      storage: 3Gi

Check new size from pvc attribute:

oc get pvc data-myapp -o yaml

Info

For OCP 3.*, you must restart the pod to take into account new size.

Check FS size from pod:

oc exec myapp -- df -h

Tips

List all CSI Ceph volume with jq:

oc get pv -o json | jq '
  .items[]
    | select(.spec.csi.driver == "openshift-storage.rbd.csi.ceph.com")
    | .spec.claimRef.namespace
        + ";" + .spec.claimRef.name
        + ";" + .spec.csi.volumeAttributes.imageName
' | tr -d '"' | column -t -s';'
Back to top