Search code examples
openshiftpersistent-volumespersistent-volume-claimstektontekton-pipelines

Automatically reclaim PersistentStorage (NFS mount) after PersistentStorageClaim is deleted?


Situation: Using Tekton tasks to build and deploy following this tutorial. After running the pipeline, it creates a pod that requires persistent volume. A persistent volume claim is automatically created to try and bind to a PV.

However, what if I want to run the pipeline again and again? I noticed after a pipeline run (right now it's failing for unrelated reasons), the PVC will no longer be needed, but the PV will be in a Released state. I can manually edit out the PVC in the YAML.

I looked into dynamic provisioning but the plug ins there do not seem to be for NFS, but rather other tools with APIs.

Is there an option for me to not have to manually reclaim my PV every time?


Solution

  • PersistentVolumes can be configured to automatically clean themselves up when released. You can configure this in your persistent volume definition at persistentvolume.spec.persistentVolumeReclaimPolicy.

    Take a look at Reclaim Volumes in the official OpenShift documentation.

    Retain reclaim policy allows manual reclamation of the resource for those volume plug-ins that support it.

    Recycle reclaim policy recycles the volume back into the pool of unbound persistent volumes once it is released from its claim.

    Delete reclaim policy deletes both the PersistentVolume object from OpenShift Container Platform and the associated storage asset in external infrastructure, such as AWS EBS or VMware vSphere.

    In your case you want to use Recyle