Helmfile: hooks not called with destroy

Created on 9 Aug 2019  路  14Comments  路  Source: roboll/helmfile

I don't see the hooks being called when I destroy a chart. I need it to call them though...can it be enabled?

Most helpful comment

I subscribe to adding predestroy and postdestroy pretty please :)

All 14 comments

Which types of hooks are you referring? (We have plenty of them like presync, postsync, cleanup etc

+1
None of the currently supported hooks (prepare, presync, postsync, cleanup) work with destroy.

exactly...no hooks at all work upon destroy

Ah that makes sense! And none of hooks doesn't fit with destroy.

So how about adding the predelete hook?

Not sure about predelete since delete is deprecated. May be predestroy?

May i know whether hooks while 'helmfile destroy' were available? like predestroy/postdestroy?

@vinayr FWIW, delete isn't deprecated. It is just a recommended alias for delete --purge!

@syenduri Not yet. But let's use this issue as a feature request to add predelete.

Ah hook that will be called when running helmfile destroy would be very helpful
+1

predestroy and postdestroy hooks would be great!

will this be implemented in the near future ?

I subscribe to adding predestroy and postdestroy pretty please :)

@mumoshu What about this:

hooks:
- events: ["presync"]
  command: "/bin/sh"
  args: ["-c", "kubectl get -R -f {{`{{ .Chart.Name }}`}}/crds/ >/dev/null 2>&1 || \
         { helm pull {{`{{ .Release.Chart }}`}} --version {{`{{ .Release.Version }}`}} && tar -Oxzf {{`{{ .Chart.Name }}`}}-{{`{{ .Release.Version }}`}}.tgz {{`{{ .Chart.Name }}`}}/crds/ | kubectl apply -R -f -; }"]

- events: ["postdestroy"]
  command: "/bin/sh"
  args: ["-c", "kubectl get -R -f {{`{{ .Chart.Name }}`}}/crds/ >/dev/null 2>&1 || \
         { helm pull {{`{{ .Release.Chart }}`}} --version {{`{{ .Release.Version }}`}} && tar -Oxzf {{`{{ .Chart.Name }}`}}-{{`{{ .Release.Version }}`}}.tgz {{`{{ .Chart.Name }}`}}/crds/ | kubectl delete -R --ignore-not-found -f -; }"]

{{ .Chart.Name }} interpolation is not available afaik ( {{ .Release.Name }} will not work in this case, but can be probably replaced by {{ (split \"/\" .Release.Chart)._1 }} )

Related: https://github.com/roboll/helmfile/issues/1124#issuecomment-626771771 https://github.com/roboll/helmfile/issues/1291#issuecomment-648358045

BTW I've named those hooks preuninstall and postuninstall following Helm 3. In Helm 3 helm delete is an alias to helm uninstall

Was this page helpful?
0 / 5 - 0 ratings

Related issues

madAndroid picture madAndroid  路  3Comments

michaelpporter picture michaelpporter  路  3Comments

mumoshu picture mumoshu  路  4Comments

pavdmyt picture pavdmyt  路  3Comments

RafalMaleska picture RafalMaleska  路  3Comments