Enabling reclaim space operation using ReclaimSpaceCronJob

ReclaimSpaceCronJob invokes the reclaim space operation based on the given schedule (daily, weekly, and so on). You have to create ReclaimSpaceCronJob one time only for a persistent volume claim. The CSI-addons controller creates a ReclaimSpaceJob at the requested time and interval with the schedule attribute.

About this task

Note:
  • Recommended schedule interval is @weekly.
  • Minimum interval between each scheduled operation should be 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 workload input/output is expected to be low.

Procedure

  1. Create and apply the following custom resource for reclaim space operation:
    apiVersion: csiaddons.openshift.io/v1alpha1
    kind: ReclaimSpaceCronJob
    metadata:
      name: reclaimspacecronjob-sample
    spec:
      jobTemplate:
        spec:
          target:
            persistentVolumeClaim: data-pvc
      schedule: '@weekly'
      concurrencyPolicy: Forbid
    concurrencyPolicy
    Describes the changes when a new ReclaimSpaceJob is scheduled by the ReclaimSpaceCronJob, while a previous ReclaimSpaceJob is still running. The default Forbid prevents starting a new job whereas Replace can be used to delete the running job potentially in a failure state and create a new one.
    failedJobsHistoryLimit
    Specifies the number of failed ReclaimSpaceJobs that are kept for troubleshooting.
    jobTemplate
    Specifies the ReclaimSpaceJob.spec structure that describes the details of the requested ReclaimSpaceJob operation.
    successfulJobsHistoryLimit
    Specifies the number of successful ReclaimSpaceJob operations.
    schedule
    Sets the and/or interval of the recurring operation. For the schedule format, see API reference > Workloads APIs > CronJob within the Red Hat OpenShift Container Platform product documentation.
  2. Delete the ReclaimSpaceCronJob customer resource after completion of the operation or when the target PVC is deleted.