From 69a4ca6d0925c4801d30f46e2434c4e4756fdcef Mon Sep 17 00:00:00 2001 From: amaslennikov Date: Mon, 29 Jul 2024 15:01:54 +0300 Subject: [PATCH] Add a pre-delete helm hook to clean up webhook configs Signed-off-by: amaslennikov --- .../templates/predeletehook.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 deployment/sriov-network-operator-chart/templates/predeletehook.yaml diff --git a/deployment/sriov-network-operator-chart/templates/predeletehook.yaml b/deployment/sriov-network-operator-chart/templates/predeletehook.yaml new file mode 100644 index 000000000..91bc64d30 --- /dev/null +++ b/deployment/sriov-network-operator-chart/templates/predeletehook.yaml @@ -0,0 +1,24 @@ +{{ if .Values.operator.admissionControllers.enabled }} +apiVersion: batch/v1 +kind: Job +metadata: + name: "{{ include "sriov-network-operator.fullname" . }}-post-delete-hook" + namespace: {{ .Release.Namespace }} + annotations: + "helm.sh/hook": pre-delete + "helm.sh/hook-delete-policy": hook-succeeded,hook-failed +spec: + template: + spec: + serviceAccountName: {{ include "sriov-network-operator.fullname" . }} + containers: + - name: cleanup + image: bitnami/kubectl:latest + command: + - /bin/sh + - -c + - | + kubectl delete MutatingWebhookConfiguration -n {{ .Release.Namespace }} sriov-operator-webhook-config network-resources-injector-config + kubectl delete ValidatingWebhookConfiguration -n {{ .Release.Namespace }} sriov-operator-webhook-config + restartPolicy: Never +{{ end }} \ No newline at end of file