You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yeah, we have this weird case where once you have created a CRD definition, other things on a cluster can become dependent on it -- notably, and CRD instances. So once we've created a CRD, it is risky to delete it. So we implemented CRD installation as a hook, which makes the CRD unmanaged (e.g. Helm doesn't delete it by default)
with "before-hook-creation" policy, the CRD is deleted immediately after it is created during helm install on a fresh cluster. It sounds like this isn't expected behavior?
(edit)
Sorry that was hook-succeeded which seems like expected behavior.
Okay, admittedly this is not my forte. What I have seen people do is launch a post-delete Job that wraps the kubectl docker image, and just runs kubectl delete on the given resource. I imagine that there are other ways of doing this that are a little less heavy handed.
This is definitely something we're aiming to fix in Helm 3. But in Helm 2 it's just sort of clunky to deal with CRDs.
@technosophos right - I understand its clunky and not hounding you up about that :). We had post-install jobs doing CRDs prior (with hyperkube) so it isn't unexpected we would need kubectl wrapped jobs. My question is more about the helm template case. With helm template, everything (including the Job that runs kubectl delete on the list of resources) would be deleted on start, vs helm installwhich will process the job only on delete.
Wondering how to make the helm template case work with a post install job (IOW ignore the job entirely) while the helm install case only runs at deletion of the chart with the unmanaged resources.
@vhosakot - the helm template case is the main use case that must be preserved. It is far more important than Helm not deleting CRDs. If I have to trade one for another, I'll keep helm template with kubectl apply -f...
What if I want to leave the crd in place, and have the restarted release continue to use it and its data?
When delete then reapply the release, it fails because the crd "already exists", due to the crd-install hook.
Is there any way around that?
Activity
technosophos commentedon Aug 7, 2018
Yeah, we have this weird case where once you have created a CRD definition, other things on a cluster can become dependent on it -- notably, and CRD instances. So once we've created a CRD, it is risky to delete it. So we implemented CRD installation as a hook, which makes the CRD unmanaged (e.g. Helm doesn't delete it by default)
So if you want to delete it, you need to explicitly tell the chart to delete it:
https://github.com/helm/helm/blob/master/docs/charts_hooks.md#hook-resources-are-not-managed-with-corresponding-releases
sdake commentedon Aug 7, 2018
@technosophos I've tried the following in our CRD charts:
which results in:
I've also tried:
I've also tried the policy
I haven't tried
hook-failed,before-hook-creationwhich may render something working - will have to try.Is the recommended technique for deleting CRDs when using
crd-installto use apost-deletehook?day0ops commentedon Aug 7, 2018
@sdake it sounds like we may require a
post-deletejob to remove the resources ?sdake commentedon Aug 7, 2018
@nixgadget hope that isn't the answer but will wait for @technosophos to weigh in.
Cheers
-steve
technosophos commentedon Aug 7, 2018
CRD deletion is slow, so using a before-hook-creation might not be fast enough.
In general, for things like CRDs it's better to delete in post-delete if possible.
There's also the
--no-hooksCLI option if you know the CRD is always there.sdake commentedon Aug 7, 2018
with "before-hook-creation" policy, the CRD is deleted immediately after it is created during
helm installon a fresh cluster. It sounds like this isn't expected behavior?(edit)
Sorry that was
hook-succeededwhich seems like expected behavior.technosophos commentedon Aug 7, 2018
Yeah -- that is used for things like Jobs where you run the job once, then delete it
day0ops commentedon Aug 7, 2018
@sdake for me in my baremetal cluster
before-hook-creationdidnt quite work as @technosophos points out.sdake commentedon Aug 7, 2018
Thanks, will sort out a post-delete hook.
day0ops commentedon Aug 7, 2018
@technosophos thanks for clarifying.
sdake commentedon Aug 7, 2018
@technosophos can you clarify how a post-delete job would work on deleting CRDs with the
helm templatecase?For further reference, a quick read of https://istio.io/docs/setup/kubernetes/helm-install/#installation-steps might help set some context. Istio 1.0 supports both
helm templateandhelm installmodels.Our CRD template is here:
https://github.com/istio/istio/blob/master/install/kubernetes/helm/istio/templates/crds.yaml
Cheers and thanks for your help - people are restless ;)
-steve
technosophos commentedon Aug 7, 2018
Okay, admittedly this is not my forte. What I have seen people do is launch a post-delete Job that wraps the
kubectldocker image, and just runskubectl deleteon the given resource. I imagine that there are other ways of doing this that are a little less heavy handed.This is definitely something we're aiming to fix in Helm 3. But in Helm 2 it's just sort of clunky to deal with CRDs.
sdake commentedon Aug 7, 2018
@technosophos right - I understand its clunky and not hounding you up about that :). We had post-install jobs doing CRDs prior (with hyperkube) so it isn't unexpected we would need kubectl wrapped jobs. My question is more about the
helm templatecase. Withhelm template, everything (including the Job that runs kubectl delete on the list of resources) would be deleted on start, vshelm installwhich will process the job only on delete.Wondering how to make the
helm templatecase work with a post install job (IOW ignore the job entirely) while thehelm installcase only runs at deletion of the chart with the unmanaged resources.Cheers
-steve
vhosakot commentedon Aug 22, 2018
I saw the same behavior today and didn't know helm doesn't delete CRDs by default (since helm installs CRDs as hook resources):
I deleted the CRDs manually.
@sdake Interesting point about
helm templatewith a post install job vshelm install:)sdake commentedon Nov 25, 2018
@vhosakot - the
helm templatecase is the main use case that must be preserved. It is far more important than Helm not deleting CRDs. If I have to trade one for another, I'll keephelm templatewithkubectl apply -f...BradyWiseman commentedon Dec 11, 2018
What if I want to leave the crd in place, and have the restarted release continue to use it and its data?
When delete then reapply the release, it fails because the crd "already exists", due to the crd-install hook.
Is there any way around that?
jaijitendra commentedon Mar 14, 2019
Any update on this issue? What is the recommeneded way to handle customresourcedefintion create in second helm install?
vsliouniaev commentedon Mar 14, 2019
@jaijitendra That's exactly the approach we have taken to make this work
natereid72 commentedon Apr 29, 2019
seems like just accepting that crd exists and moving on would be best option.
allamand commentedon Jun 5, 2019
I like the idea of the cli option --no-hooks to re-install with leaving existing crd in place
bacongobbler commentedon May 14, 2020
closing as inactive.