{{- if and (.Values.webhook.enabled) (.Values.legacy.enabled) }} # HELM first deletes RBAC, then it tries to delete other resources like SPC and PVC. # We've got validating webhook on SPC and PVC. # But even that the policy of this webhook is Ignore, it fails because the ServiceAccount # does not have permission to access resources like BDC anymore which are used for validation. # Therefore we first need to delete webhook so we can delete the rest of the deployments. {{- $kubeMinor := .Capabilities.KubeVersion.Minor | replace "+" "" }} apiVersion: batch/v1 kind: Job metadata: name: {{ template "openebs.fullname" . }}-webhook-cleanup namespace: {{ .Release.Namespace }} annotations: "helm.sh/hook": pre-delete "helm.sh/hook-delete-policy": hook-succeeded labels: app: {{ template "openebs.name" . }} spec: template: metadata: name: {{ template "openebs.fullname" . }}-webhook-cleanup labels: app: {{ template "openebs.name" . }} spec: {{- if .Values.cleanup.image.imagePullSecrets }} imagePullSecrets: {{ toYaml .Values.cleanup.image.imagePullSecrets | indent 8 }} {{- end }} serviceAccountName: {{ template "openebs.serviceAccountName" . }} {{- if .Values.webhook.tolerations }} tolerations: {{ toYaml .Values.webhook.tolerations | indent 8 }} {{- end }} containers: - name: kubectl {{- /* bitnami maintains an image for all k8s versions */}} {{- /* see: https://hub.docker.com/r/bitnami/kubectl */}} {{- if .Values.cleanup.image.tag }} image: "{{ .Values.cleanup.image.registry }}{{ .Values.cleanup.image.repository }}:{{ .Values.cleanup.image.tag }}" {{- else }} image: "{{ .Values.cleanup.image.registry }}{{ .Values.cleanup.image.repository }}:{{ .Capabilities.KubeVersion.Major }}.{{ $kubeMinor }}" {{- end }} command: - /bin/sh - -c - > kubectl delete validatingWebhookConfiguration openebs-validation-webhook-cfg || true; restartPolicy: OnFailure {{- end }}