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.

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'
    failedJobsHistoryLimit
    Keeps the number of failed ReclaimSpaceJobs.
    jobTemplate
    Contains ReclaimSpaceJob.spec structure which includes the requested ReclaimSpaceJob operation.
    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.
    successfulJobsHistoryLimit
    Keeps the number of successful ReclaimSpaceJob operations.
  2. Delete the customer resource after completion of the operation.