post-delete-hook-job.yaml 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. {{- if .Values.postDelete.enabled }}
  2. apiVersion: batch/v1
  3. kind: Job
  4. metadata:
  5. name: {{ template "rancher.fullname" . }}-post-delete
  6. namespace: {{ .Release.Namespace }}
  7. labels: {{ include "rancher.labels" . | nindent 4 }}
  8. annotations:
  9. "helm.sh/hook": post-delete
  10. "helm.sh/hook-weight": "3"
  11. "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
  12. spec:
  13. backoffLimit: 3
  14. template:
  15. metadata:
  16. name: {{ template "rancher.fullname" . }}-post-delete
  17. labels: {{ include "rancher.labels" . | nindent 8 }}
  18. spec:
  19. serviceAccountName: {{ template "rancher.fullname" . }}-post-delete
  20. restartPolicy: OnFailure
  21. containers:
  22. - name: {{ template "rancher.name" . }}-post-delete
  23. image: "{{ include "system_default_registry" . }}{{ .Values.postDelete.image.repository }}:{{ .Values.postDelete.image.tag }}"
  24. imagePullPolicy: IfNotPresent
  25. securityContext:
  26. runAsUser: 0
  27. command:
  28. - /scripts/post-delete-hook.sh
  29. volumeMounts:
  30. - mountPath: /scripts
  31. name: config-volume
  32. env:
  33. - name: NAMESPACES
  34. value: {{ .Values.postDelete.namespaceList | join " " | quote }}
  35. - name: RANCHER_NAMESPACE
  36. value: {{ .Release.Namespace }}
  37. - name: TIMEOUT
  38. value: {{ .Values.postDelete.timeout | quote }}
  39. - name: IGNORETIMEOUTERROR
  40. value: {{ .Values.postDelete.ignoreTimeoutError | quote }}
  41. volumes:
  42. - name: config-volume
  43. configMap:
  44. name: {{ template "rancher.fullname" . }}-post-delete
  45. defaultMode: 0777
  46. {{- end }}