I’m installing a Helm chart via KOTS and trying to add some logic that depends on whether it’s running an initial install or upgrade. Helm’s IsInstall and IsUpgrade values are always set to true and false, respectively, when I install via KOTS though it works as expected when I install via Helm directly.
To test a few permutations, I added some annotations and saw that these values never varied when installing and upgrading via kots:
Specifically, I’m trying to find a way to generate a random password at initial install and not overwrite it during later updates – the password is stored in a k8s secret. I’d appreciate a workaround for this that doesn’t depend on the IsInstall / IsUpgrade values if you anyone has recommendations.
My understanding from elsewhere is that the most common methods, including using lookup, aren’t supported due to how Replicated works internally.
The values for .Release.IsInstall and .Release.IsUpgrade will always be true and false respectively because KOTS runs a helm template on the chart before installing so that additional kustomize patches can be applied to the generated resources (pull secrets, image re-writes, etc). The kustomize output is then installed with helm upgrade -i, but by that point, those template functions have already been rendered.
Here is some more information about how the .Release object will behave in KOTS when using native Helm:
.Release.IsInstall - always true
.Release.IsUpgrade - always false
.Release.Name - the HelmChart resource spec.chart.releaseName or spec.chart.name if a release name is not specified
.Release.Namespace - the HelmChart resource spec.namespace or the admin console namespace if one is not specified