Enabling reclaim space operation using Annotating PersistentVolumeClaims

Enable reclaim space operations using Annotating PersistentVolumeClaims.

About this task

Use this procedure to annotate PersistentVolumeClaims so that it can invoke the reclaim space operation automatically based on a given schedule.
Note:
  • 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, using the pvc data-pvc command.
    $ oc get pvc data-pvc
    For example:
    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.
    For example:
    $ oc annotate pvc data-pvc "reclaimspace.csiaddons.openshift.io/schedule=@monthly"
    Output example:
    persistentvolumeclaim/data-pvc annotated
  3. Verify that reclaimspacecronjob is created in the following format:
    <pvc-name>-xxxxxxx
    $ oc get reclaimspacecronjobs.csiaddons.openshift.io

    For example:

    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
    For example:
    persistentvolumeclaim/data-pvc annotated
  5. Verify that the schedule for reclaimspacecronjob has been modified.
    oc get reclaimspacecronjobs.csiaddons.openshift.io
    For example:
    NAME                  SCHEDULE    SUSPEND   ACTIVE   LASTSCHEDULE   AGE
    data-pvc-1642664617   @weekly                                      3s