Factory/rancher-turtles-chart/templates/pre-delete-job.yaml
Nicolas Belouin b39277a6cb Add rancher turtles charts
Signed-off-by: Nicolas Belouin <nicolas.belouin@suse.com>
2024-10-31 16:54:18 +01:00

68 lines
1.6 KiB
YAML

{{- 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 }}