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 used 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 used when the volume is not attached to any pods and reclaims the space occupied by chunks of 4M-sized zeroed data.
- Only the Ceph RBD volumes support the reclaim space operation.
- 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
10.1. Enabling reclaim space operation by annotating PersistentVolumeClaims 링크 복사링크가 클립보드에 복사되었습니다!
Use this procedure to automatically invoke the reclaim space operation to annotate persistent volume claim (PVC) based on a given schedule.
-
The schedule value is in the same format as the Kubernetes CronJobs which sets the
and/orinterval 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. Do not schedule multipleReclaimSpaceoperations@weeklyor at the same time. -
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 workloadinput/outputis expected to be low. -
ReclaimSpaceCronJobis recreated when thescheduleis modified. It is automatically deleted when the annotation is removed.
Procedure
Get the 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