From 652bf222e4f81f425c9143be51dfcb86bad92a7d Mon Sep 17 00:00:00 2001 From: amaslennikov Date: Mon, 29 Jul 2024 15:40:11 +0300 Subject: [PATCH] Backport a pre-delete helm hook for sriov-network-operator Mutating and Validating webhook configs are created programmatically and are not managed by helm. To clean them up on helm delete, adding a small pre-delete hook https://github.com/k8snetworkplumbingwg/sriov-network-operator/pull/751 Signed-off-by: amaslennikov --- .../templates/predeletehook.yaml | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 deployment/network-operator/charts/sriov-network-operator/templates/predeletehook.yaml diff --git a/deployment/network-operator/charts/sriov-network-operator/templates/predeletehook.yaml b/deployment/network-operator/charts/sriov-network-operator/templates/predeletehook.yaml new file mode 100644 index 00000000..9148f7e5 --- /dev/null +++ b/deployment/network-operator/charts/sriov-network-operator/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 }}