You can download this article in PDF format via the link below to support us.
Download the guide in PDF format turn off
The OpenShift container platform uses the Kubernetes Persistent Volume (PV) framework, allowing cluster administrators to provide persistent storage for cluster operations that require data persistence. As a developer, you can use persistent volume claims (PVC) to request PV resources without having to understand the underlying storage infrastructure.
In this short guide, you will learn how to extend an existing PVC in OpenShift when using OpenShift container storage.Before extending a persistent volume, the StorageClass must have allowVolumeExpansion The field is set to true.
This is a list of storage classes available in the OpenShift cluster.
$ oc get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
localblock kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 186d
localfile kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 186d
ocs-storagecluster-ceph-rbd openshift-storage.rbd.csi.ceph.com Delete Immediate false 169d
ocs-storagecluster-cephfs (default) openshift-storage.cephfs.csi.ceph.com Delete Immediate true 169d
openshift-storage.noobaa.io openshift-storage.noobaa.io/obc Delete Immediate false 169d
thin kubernetes.io/vsphere-volume Delete Immediate false 169d
unused kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 190d
I will change the default storage class ocs-storagecluster-cephfs . Let’s export the configuration to a yaml file:
oc get sc ocs-storagecluster-cephfs -o yaml >ocs-storagecluster-cephfs.yml
I will modify the file to add the allowVolumeExpansion field.
allowVolumeExpansion: true
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
storageclass.kubernetes.io/is-default-class: "true"
name: ocs-storagecluster-cephfs
parameters:
clusterID: openshift-storage
csi.storage.k8s.io/node-stage-secret-name: rook-csi-cephfs-node
csi.storage.k8s.io/node-stage-secret-namespace: openshift-storage
csi.storage.k8s.io/provisioner-secret-name: rook-csi-cephfs-provisioner
csi.storage.k8s.io/provisioner-secret-namespace: openshift-storage
fsName: ocs-storagecluster-cephfilesystem
provisioner: openshift-storage.cephfs.csi.ceph.com
reclaimPolicy: Delete
volumeBindingMode: Immediate
allowVolumeExpansion: true # Added field
Since SC is an immutable resource, please delete the currently configured storage class.
$ oc delete sc ocs-storagecluster-cephfs
storageclass.storage.k8s.io "ocs-storagecluster-cephfs" deleted
Apply the modified storage class configuration by running the following command:
$ oc apply -f ocs-storagecluster-cephfs.yml
storageclass.storage.k8s.io/ocs-storagecluster-cephfs created
List the storage class to confirm that it has indeed been created.
$ oc get sc
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
localblock kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 186d
localfile kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 186d
ocs-storagecluster-ceph-rbd openshift-storage.rbd.csi.ceph.com Delete Immediate false 169d
ocs-storagecluster-cephfs (default) openshift-storage.cephfs.csi.ceph.com Delete Immediate true 5m20s
openshift-storage.noobaa.io openshift-storage.noobaa.io/obc Delete Immediate false 169d
thin kubernetes.io/vsphere-volume Delete Immediate false 169d
unused kubernetes.io/no-provisioner Delete WaitForFirstConsumer false 190d
Output Yalm and confirm that the new settings have been applied.
$ oc get sc ocs-storagecluster-cephfs -o yaml
allowVolumeExpansion: true
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"allowVolumeExpansion":true,"apiVersion":"storage.k8s.io/v1","kind":"StorageClass","metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"},"name":"ocs-storagecluster-cephfs"},"parameters":{"clusterID":"openshift-storage","csi.storage.k8s.io/node-stage-secret-name":"rook-csi-cephfs-node","csi.storage.k8s.io/node-stage-secret-namespace":"openshift-storage","csi.storage.k8s.io/provisioner-secret-name":"rook-csi-cephfs-provisioner","csi.storage.k8s.io/provisioner-secret-namespace":"openshift-storage","fsName":"ocs-storagecluster-cephfilesystem"},"provisioner":"openshift-storage.cephfs.csi.ceph.com","reclaimPolicy":"Delete","volumeBindingMode":"Immediate"}
storageclass.kubernetes.io/is-default-class: "true"
creationTimestamp: "2020-10-31T13:33:56Z"
name: ocs-storagecluster-cephfs
resourceVersion: "242503097"
selfLink: /apis/storage.k8s.io/v1/storageclasses/ocs-storagecluster-cephfs
uid: 5aa95d3b-c39c-438d-85af-5c8550d6ed5b
parameters:
clusterID: openshift-storage
csi.storage.k8s.io/node-stage-secret-name: rook-csi-cephfs-node
csi.storage.k8s.io/node-stage-secret-namespace: openshift-storage
csi.storage.k8s.io/provisioner-secret-name: rook-csi-cephfs-provisioner
csi.storage.k8s.io/provisioner-secret-namespace: openshift-storage
fsName: ocs-storagecluster-cephfilesystem
provisioner: openshift-storage.cephfs.csi.ceph.com
reclaimPolicy: Delete
volumeBindingMode: Immediate
How to expand PVC in OpenShift
List the available PVCs in the namespace.
$ oc get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
data-harbor-harbor-redis-0 Bound pvc-e516b793-60c5-431d-955f-b1d57bdb556b 1Gi RWO ocs-storagecluster-cephfs 169d
database-data-harbor-harbor-database-0 Bound pvc-00a53065-9790-4291-8f00-288359c00f6c 2Gi RWO ocs-storagecluster-cephfs 169d
harbor-harbor-chartmuseum Bound pvc-405c68de-eecd-4db1-9ca1-5ca97eeab37c 5Gi RWO ocs-storagecluster-cephfs 169d
harbor-harbor-jobservice Bound pvc-e52f231e-0023-41ad-9aff-98ac53cecb44 2Gi RWO ocs-storagecluster-cephfs 169d
harbor-harbor-registry Bound pvc-77e159d4-4059-47dd-9c61-16a6e8b37a14 100Gi RWX ocs-storagecluster-cephfs 39d
Edit PVC and change capacity
$ oc edit pvc data-harbor-harbor-redis-0
...
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
Delete the advertising chain with copyright claims.
$ oc delete pods harbor-harbor-redis-0
pod "harbor-harbor-redis-0" deleted
Recreate the deployment declaring the storage, and the deployment should utilize the new capacity.
Expand PVC on OpenShift web console
You can also extend the PVC from the web console.
Click” Expand PVC” And set the required PVC capacity.
More articles about OpenShift.
How to deploy Ubuntu Pod in Kubernetes | OpenShift
Configure static IPv4 address in OpenShift 4.x CoreOS server
How to list and approve pending CSRs in OpenShift 4.x
You can download this article in PDF format via the link below to support us.
Download the guide in PDF format turn off