第 10 章 Reclaiming space on target volumes
The deleted files or chunks of zero data Sometimes take up storage space on the Ceph cluster resulting in inaccurate reporting of the available storage space. The reclaim space operation removes such discrepancies by executing the following operations on the target volume:
-
fstrim- This operation is executed on volumes that are inFilesystemmode and only if the volume is mounted to a pod at the time of execution of reclaim space operation. -
rbd sparsify- This operation is executed when the volume is not attached to any pods and reclaims the space occupied by chunks of 4M-sized zeroed data.
- The reclaim space operation is supported only by the Ceph RBD volumes.
- The reclaim space operation involves a performance penalty when it is being executed.
You can use one of the following methods to reclaim the space:
- Enabling reclaim space operation using Annotating PersistentVolumeClaims (Recommended method to use for enabling reclaim space operation)
- Enabling reclaim space operation using ReclaimSpaceJob
- Enabling reclaim space operation using ReclaimSpaceCronJob
Use this procedure to annotate PersistentVolumeClaims so that it can invoke the reclaim space operation automatically based on a given schedule.
- The schedule value is in the same format as the Kubernetes CronJobs which sets the and/or interval of the recurring operation request.
-
Recommended schedule interval is
@weekly. If the schedule interval value is empty or in an invalid format, then the default schedule value is set to@weekly. -
Minimum supported interval between each scheduled operation is at least 24 hours. For example,
@daily(At 00:00 every day) or0 3 * * *(At 3:00 every day). -
Schedule the
ReclaimSpaceoperation during off-peak, maintenance window, or the interval when the workload input/output is expected to be low. -
ReclaimSpaceCronJobis recreated when thescheduleis modified. It is automatically deleted when the annotation is removed.
Procedure
Get the persistent volume claim (PVC) details.
$ oc get pvc data-pvcNAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE data-pvc Bound pvc-f37b8582-4b04-4676-88dd-e1b95c6abf74 1Gi RWO ocs-storagecluster-ceph-rbd 20hAdd annotation
reclaimspace.csiaddons.openshift.io/schedule=@monthlyto the PVC to createreclaimspacecronjob.$ oc annotate pvc data-pvc "reclaimspace.csiaddons.openshift.io/schedule=@monthly"persistentvolumeclaim/data-pvc annotatedVerify that
reclaimspacecronjobis created in the format,"<pvc-name>-xxxxxxx".$ oc get reclaimspacecronjobs.csiaddons.openshift.ioNAME SCHEDULE SUSPEND ACTIVE LASTSCHEDULE AGE data-pvc-1642663516 @monthly 3sModify the schedule to run this job automatically.
$ oc annotate pvc data-pvc "reclaimspace.csiaddons.openshift.io/schedule=@weekly" --overwrite=truepersistentvolumeclaim/data-pvc annotatedVerify that the schedule for
reclaimspacecronjobhas been modified.$ oc get reclaimspacecronjobs.csiaddons.openshift.ioNAME SCHEDULE SUSPEND ACTIVE LASTSCHEDULE AGE data-pvc-1642664617 @weekly 3s