Deleting Helm releases #48
Description
Kube-janitor seems perfect for auto-cleaning of temp. feature deploys. But... we use Helm. So it would remove the resources and leave the release data (secret objects) dangling.
Possible ways to cleanup helm releases could be:
Determine release and use helm to uninstall
- Determine helm release name from the resources found, e.g. based on labels
heritage: Helm
andrelease: <release-name>
. - Instead of removing individual resources, shell out to helm, executing
helm uninstall <release-name>
.
Some pros/cons:
- Pro: Applications installed by helm are probably best uninstalled by helm. There might be hooks, resources not annotated, etc. It would be consistent by design.
- Con: Major change in
kube-janitor
. Shell commands, helm binary requirement. Violates linux mantra 'do one thing well'.
Find helm release secret object and remove that as well
- Determine helm release name from the resources found, e.g. based on labels
heritage: Helm
andrelease: <release-name>
. - Helm release data would be in a secret having label
name: <release-name>
and a name likesh.helm.release.v1.<release-name>.v1
.
Some pros/cons:
- Pro: Relatively easy to add to
kube-janitor
- Con: Might leave resources that aren't annotated. This is already the case with current operation of
kube-janitor
but when using helm charts not authored yourself, you're dependent on the ability of the chart to annotate all resources. Note that this restriction doesn't seem to apply when using kube-janitor with a rules file. If I'm not mistaken that doesn't require having annotations on each resource.
Any implementation would obviously be 'opt in' and might require some additional config options or logic, e.g. an annotation specifying the label to extract the helm release from.
I'd like to hear your thoughts. Personally I think the 2nd approach would be a fit for kube-janitor
while 1st approach has risk of embedding what would become a parallel completely new implementation.
Coming days (given time, 🎄after all) I'll try to run some tests to see how Helm copes with possible dangling resources, while release data has been removed.