I am using bitnami/mongodb as a dependency for my helm chart. With this chart autogenerating secrets for e.g. mongodb.auth.rootPassword on install, I want to use the existing secret upon updating the chart, instead of the "empty value" which causes auto generation.
To be clear: The above is just an example / my usecase, the following question is a general question regarding Helm.
Is there any variable in helm to check wether it is an install or an update?
In the context of using a third-party chart, the only thing you can really do is to create the password outside of Helm and inject it (using a
-f my-values.yamlfile or the--setoption). The Bitnami MySQL chart has a more specific note on upgrading:If you controlled the template, in principle you can check
.Release.IsUpgradebut it won't actually help you here. If you had template code likewhat it would actually do, on upgrade, is notice that the set of Kubernetes manifests doesn't include the Secret object any more, and delete it.
I'd avoid using the Sprig functions to randomly generate a password, or chart-level options to generate one, specifically because Helm doesn't have any way to remember the password and it will get overwritten on every upgrade.