This repository has been archived by the owner on Feb 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16.8k
/
cleanup-crds.yaml
43 lines (43 loc) · 1.75 KB
/
cleanup-crds.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
{{- if and .Values.prometheusOperator.enabled .Values.prometheusOperator.cleanupCustomResource }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ template "prometheus-operator.fullname" . }}-operator-cleanup
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": pre-delete
"helm.sh/hook-weight": "3"
"helm.sh/hook-delete-policy": hook-succeeded
labels:
app: {{ template "prometheus-operator.name" . }}-operator
{{ include "prometheus-operator.labels" . | indent 4 }}
spec:
template:
metadata:
name: {{ template "prometheus-operator.fullname" . }}-operator-cleanup
labels:
app: {{ template "prometheus-operator.name" . }}-operator
{{ include "prometheus-operator.labels" . | indent 8 }}
spec:
{{- if .Values.global.rbac.create }}
serviceAccountName: {{ template "prometheus-operator.operator.serviceAccountName" . }}
{{- end }}
containers:
- name: kubectl
image: "{{ .Values.prometheusOperator.hyperkubeImage.repository }}:{{ .Values.prometheusOperator.hyperkubeImage.tag }}"
imagePullPolicy: "{{ .Values.prometheusOperator.hyperkubeImage.pullPolicy }}"
command:
- /bin/sh
- -c
- >
kubectl delete alertmanager --all;
kubectl delete prometheus --all;
kubectl delete prometheusrule --all;
kubectl delete servicemonitor --all;
sleep 10;
kubectl delete crd alertmanagers.monitoring.coreos.com;
kubectl delete crd prometheuses.monitoring.coreos.com;
kubectl delete crd prometheusrules.monitoring.coreos.com;
kubectl delete crd servicemonitors.monitoring.coreos.com;
restartPolicy: OnFailure
{{- end }}