title: How not to overwrite randomly generated secrets in Helm templates
body: <p>I want to generate a password in a Helm template, this is easy to do using the <code>randAlphaNum</code> function. However the password will be changed when the release is upgraded. Is there a way to check if a password was previously generated and then use the existing value? Something like this:</p>
  
  <pre><code>apiVersion: v1
  kind: Secret
  metadata:
    name: db-details
  data:
    {{ if .Secrets.db-details.db-password }}
    db-password:  {{ .Secrets.db-details.db-password | b64enc }}
    {{ else }}
    db-password: {{ randAlphaNum 20 | b64enc }}
    {{ end }}
  </code></pre>