Skip to content

Commit

Permalink
feat: add pre-delete-hook
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Csati <[email protected]>
  • Loading branch information
csatib02 committed Nov 29, 2024
1 parent c8c335d commit 1399f11
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions charts/logging-operator/templates/pre-delete-hook.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Release.Name }}-pre-delete-hook
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
annotations:
helm.sh/hook: pre-delete
helm.sh/hook-weight: "-5"
helm.sh/hook-delete-policy: hook-succeeded
spec:
template:
metadata:
name: "{{ .Release.Name }}"
labels:
app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
app.kubernetes.io/instance: {{ .Release.Name | quote }}
helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
spec:
restartPolicy: Never
{{- if .Values.rbac.serviceAccountName }}
serviceAccountName: {{ .Values.rbac.serviceAccountName }}
{{- else if .Values.rbac.enabled }}
serviceAccountName: {{ include "logging-operator.fullname" . }}
{{- end }}
containers:
- name: delete-logging
image: bitnami/kubectl:latest
imagePullPolicy: IfNotPresent
command:
- /bin/sh
- -c
- kubectl delete logging --all

- name: delete-syslogngconfig
image: bitnami/kubectl:latest
command:
- /bin/sh
- -c
- |
namespaces=$(kubectl get namespaces --no-headers -o custom-columns=":metadata.name")
for ns in $namespaces; do
echo "Deleting syslogngconfig resources in namespace: $ns"
kubectl delete syslogngconfig --all --namespace="$ns" || echo "Failed to delete syslogngconfig in $ns"
done
- name: delete-fluentdconfig
image: bitnami/kubectl:latest
command:
- /bin/sh
- -c
- |
namespaces=$(kubectl get namespaces --no-headers -o custom-columns=":metadata.name")
for ns in $namespaces; do
echo "Deleting fluentdconfig resources in namespace: $ns"
kubectl delete fluentdconfig --all --namespace="$ns" || echo "Failed to delete fluentdconfig in $ns"
done

0 comments on commit 1399f11

Please sign in to comment.