Helm Release.IsInstall and IsUpgrade are inaccurate

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:

    test.io/is-install: {{ $.Release.IsInstall | quote }} # always `true` with kots
    test.io/is-upgrade: {{ $.Release.IsUpgrade | quote }} # always `false` with kots

Is this expected? I would expect the behavior to be identical to Helm.

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
  • .Release.Revision - always 1
  • .Release.Service - always Helm

Does it means that before upgrade of application performed helm uninstall? I saw this in logs of kotsadm.log.

{"level":"info","ts":"2023-05-12T12:53:56Z","msg":"running helm with arguments [uninstall my-app -n default]"}
{"level":"info","ts":"2023-05-12T12:53:57Z","msg":"stdout (helm uninstall) = release \"my-app\" uninstalled\n"}
{"level":"info","ts":"2023-05-12T12:53:57Z","msg":"stderr (helm uninstall) = "}

What exactly happening when you press ‘Deploy’ button agains new version of application? Currently my pre-upgrade hooks stop working and I don’t get why.