<p>I have a secret resource templates that upon installation will generate random values for the data.</p>

<p>I run into a problem after removing that chart (which did not delete the secret resource, because those stay), and reinstalling it later.</p>

<p>That caused it to run over the previous secret with newly generated data, which is not desired in my case.</p>

<p>I'm trying to find what is the if condition I need to include in the template so that it will not create or modify the secret if it already exists. How do I do that?</p>

<p>From helm 3.1 version onwards, there is a lookup function available to check if the given resource exists or not. Using this function you can skip the upgrading or installing a resource if it already exists.</p>
<p><a href="https://helm.sh/docs/chart_template_guide/functions_and_pipelines/#using-the-lookup-function" rel="noreferrer">Lookup function</a></p>
<p>For example, see this <a href="https://github.com/sankalp-r/helm-charts-examples" rel="noreferrer">sample-chart</a>. I have created a function named <code>gen.secret</code> in _helpers.tpl and used it in secret.yaml</p>
