Reputation: 14736
I create a K8S Secret with Helm in a pre-install hook.
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 K8S Secret as-well.
Everything works fine, except the secret is not deleted after uninstallation.
apiVersion: v1
kind: Secret
metadata:
name: secret-name
namespace: sample
labels:
app.kubernetes.io/managed-by: "sample"
app.kubernetes.io/instance: "sample"
app.kubernetes.io/version: "1.1"
annotations:
"helm.sh/hook": pre-install
"helm.sh/hook-weight": "-1"
type: Opaque
stringData:
user: "test-user"
password: {{ randAlphaNum 10 | quote }}
In the documentation, there is the hook-delete-policy
annotation, but the possible values are
In my case, none of the options seem to be right.
How can I automatically delete the K8S Secret at uninstall time?
Upvotes: 1
Views: 3323
Reputation: 1403
Why not just use post-delete
along with pre-install
?
post-delete -- Executes on a deletion request after all of the release's resources have been deleted
annotations:
"helm.sh/hook": post-delete
"helm.sh/hook": pre-install
Upvotes: -1