PVC for helm hook jobs

61 Views Asked by At

I have a helm chart with the following resources:

  • deployment.yaml
  • job.yaml
  • pv.yaml
  • pvc.yaml
  • service.yaml
  • ingress.yaml
  • secretproviderclass.yaml

I configured the Job as a helm hook:

apiVersion: batch/v1
kind: Job
metadata:
  name: "job-myapp"
  annotations:
    # Defines this resource as a hook. Otherwise,considered as part of the release.
    "helm.sh/hook": pre-install,pre-upgrade
    "helm.sh/hook-weight": "1"
    "helm.sh/hook-delete-policy": before-hook-creation

This job requires the PVC,PV and the secrets created by secretproviderclass (Azure) to work.

But when I install the helm chart for the first time, the job pods get into a pending state with an error saying the pvc is not found.

This error is because the hooks are expecting pvc and pv before starting it. But that is supposed to be created by Helm only if the Job is successful! It's an egg-chicken problem now!

Jobs may succeed if I add pv, pvc, and secretproviderclass as hooks with lesser weights. But Helm will not manage these resources as part of the release from there onwards!

What is a good approach to solving this problem?

0

There are 0 best solutions below