Home > front end >  Define some policies to remove a persistent volume claim after a workflow has completed successfully
Define some policies to remove a persistent volume claim after a workflow has completed successfully

Time:12-18

I have a workflow where a persistent volume is created however, the volume is not removed after the job has finished successfully.

  volumeClaimTemplates:
    - metadata:
        name: some_volume
      spec:
        accessModes: ['ReadWriteMany']
        resources:
          requests:
            storage: 2Gi

I have been looking for some policy that can be set to remove the volume after the workflow has finished successfully however, I could not find anything. Someone suggested creating a cronjob to remove the volume. But is there an easier way to define some policies to remove a persistent volume claim after the workflow has finished successfully?

CodePudding user response:

The persistent volume will be deleted by setting podGC and volumeClaimGC:

spec:
  entrypoint: main
  volumeClaimGC:
    strategy: OnWorkflowCompletion
  podGC:
    strategy: OnPodSuccess
  volumeClaimTemplates:
  - metadata:
      name: test-volume
    spec:
      accessModes: ['ReadWriteMany']
      resources:
        requests:
          storage: 1Gi
  • Related