第 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 in Filesystem mode 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) or 0 3 * * * (At 3:00 every day).
  • Schedule the ReclaimSpace operation during off-peak, maintenance window, or the interval when the workload input/output is expected to be low.
  • ReclaimSpaceCronJob is recreated when the schedule is modified. It is automatically deleted when the annotation is removed.

Procedure

  1. Get the persistent volume claim (PVC) details.

    $ oc get pvc data-pvc
    NAME      STATUS   VOLUME                                     CAPACITY   ACCESS MODES   STORAGECLASS                          AGE
    data-pvc  Bound    pvc-f37b8582-4b04-4676-88dd-e1b95c6abf74   1Gi        RWO            ocs-storagecluster-ceph-rbd           20h
  2. Add annotation reclaimspace.csiaddons.openshift.io/schedule=@monthly to the PVC to create reclaimspacecronjob.

    $ oc annotate pvc data-pvc "reclaimspace.csiaddons.openshift.io/schedule=@monthly"
    persistentvolumeclaim/data-pvc annotated
  3. Verify that reclaimspacecronjob is created in the format, "<pvc-name>-xxxxxxx".

    $ oc get reclaimspacecronjobs.csiaddons.openshift.io
    NAME                    SCHEDULE    SUSPEND   ACTIVE   LASTSCHEDULE   AGE
    data-pvc-1642663516     @monthly                                      3s
  4. Modify the schedule to run this job automatically.

    $ oc annotate pvc data-pvc "reclaimspace.csiaddons.openshift.io/schedule=@weekly" --overwrite=true
    persistentvolumeclaim/data-pvc annotated
  5. Verify that the schedule for reclaimspacecronjob has been modified.

    $ oc get reclaimspacecronjobs.csiaddons.openshift.io
    NAME                  SCHEDULE    SUSPEND   ACTIVE   LASTSCHEDULE   AGE
    data-pvc-1642664617   @weekly                                       3s
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

关于红帽文档

Legal Notice

Theme

© 2026 Red Hat
返回顶部