<p>I create a <em>K8S Secret</em> with Helm in a <em>pre-install hook</em>.</p>
<p>This secret is a random password for a database user. When I uninstall the Helm Chart I delete the database and the database user, so I'd like to delete the <em>K8S Secret</em> as-well.</p>
<p>Everything works fine, except the secret is not deleted after uninstallation.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: Secret
metadata:
  name: secret-name
  namespace: sample
  labels:
    app.kubernetes.io/managed-by: &quot;sample&quot;
    app.kubernetes.io/instance: &quot;sample&quot;
    app.kubernetes.io/version: &quot;1.1&quot;
  annotations:
    &quot;helm.sh/hook&quot;: pre-install
    &quot;helm.sh/hook-weight&quot;: &quot;-1&quot;
type: Opaque
stringData:
  user: &quot;test-user&quot;
  password: {{ randAlphaNum 10 | quote }}
</code></pre>
<p><a href="https://helm.sh/docs/topics/charts_hooks/#hook-deletion-policies" rel="nofollow noreferrer">In the documentation</a>, there is the <code>hook-delete-policy</code> annotation, but the possible values are</p>
<ul>
<li>before-hook-creation</li>
<li>hook-succeeded</li>
<li>hook-failed</li>
</ul>
<p>In my case, none of the options seem to be right.</p>
<p>How can I automatically delete the K8S Secret at uninstall time?</p>

<p>Why not just use <code>post-delete</code> along with <code>pre-install</code>?</p>
<blockquote>
<p>post-delete   -- Executes on a deletion request after all of the
release's resources have been deleted</p>
</blockquote>
<pre><code>annotations:
  &quot;helm.sh/hook&quot;: post-delete
  &quot;helm.sh/hook&quot;: pre-install
</code></pre>
