{{- if index .Values "rancherTurtles" "features" "rancher-webhook" "cleanup" }} --- apiVersion: v1 kind: ServiceAccount metadata: name: pre-delete-job namespace: rancher-turtles-system annotations: "helm.sh/hook": pre-delete "helm.sh/hook-weight": "-2" --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: pre-delete-job-delete-capiproviders annotations: "helm.sh/hook": pre-delete "helm.sh/hook-weight": "-2" rules: - apiGroups: - turtles-capi.cattle.io resources: - capiproviders verbs: - list - delete --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: pre-delete-job-capiprovider-cleanup annotations: "helm.sh/hook": pre-delete "helm.sh/hook-weight": "-2" subjects: - kind: ServiceAccount name: pre-delete-job namespace: rancher-turtles-system roleRef: kind: ClusterRole name: pre-delete-job-delete-capiproviders apiGroup: rbac.authorization.k8s.io --- apiVersion: batch/v1 kind: Job metadata: name: rancher-capiprovider-cleanup namespace: rancher-turtles-system annotations: "helm.sh/hook": pre-delete "helm.sh/hook-weight": "-1" spec: ttlSecondsAfterFinished: 300 template: spec: serviceAccountName: pre-delete-job containers: - name: rancher-capiprovider-cleanup image: {{ index .Values "rancherTurtles" "features" "rancher-webhook" "kubectlImage" }} args: - delete - capiproviders - -A - --all - --cascade=foreground restartPolicy: Never {{- end }}