Skip to content

Commit

Permalink
Cleanup jobs back to cronjob (#2952)
Browse files Browse the repository at this point in the history
In case of corner cases in which succeeded jobs remain for whatever reason (most likely events loss due to heavy loaded system) it is useful to still run the cleanup job daily.

This will still delete only succeded jobs. Any job in error state or running will be kept.

Signed-off-by: Xavi Garcia <[email protected]>
  • Loading branch information
0xavi0 authored Oct 10, 2024
1 parent 8e7f709 commit c3829bf
Showing 1 changed file with 36 additions and 33 deletions.
69 changes: 36 additions & 33 deletions charts/fleet/templates/job_cleanup_gitrepojobs.yaml
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
{{- if .Values.migrations.gitrepoJobsCleanup }}
---
apiVersion: batch/v1
kind: Job
kind: CronJob
metadata:
name: fleet-cleanup-gitrepo-jobs
annotations:
"helm.sh/hook": post-install, post-upgrade
"helm.sh/hook-delete-policy": hook-succeeded, before-hook-creation
spec:
template:
metadata:
labels:
app: fleet-job
schedule: "@daily"
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 0
failedJobsHistoryLimit: 1
jobTemplate:
spec:
serviceAccountName: gitjob
restartPolicy: Never
securityContext:
runAsNonRoot: true
runAsGroup: 1000
runAsUser: 1000
containers:
- name: cleanup
image: "{{ template "system_default_registry" . }}{{.Values.image.repository}}:{{.Values.image.tag}}"
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: false
privileged: false
command:
- fleet
args:
- cleanup
- gitjob
nodeSelector: {{ include "linux-node-selector" . | nindent 8 }}
tolerations: {{ include "linux-node-tolerations" . | nindent 8 }}
backoffLimit: 1
template:
metadata:
labels:
app: fleet-job
spec:
serviceAccountName: gitjob
restartPolicy: Never
securityContext:
runAsNonRoot: true
runAsGroup: 1000
runAsUser: 1000
containers:
- name: cleanup
image: "{{ template "system_default_registry" . }}{{.Values.image.repository}}:{{.Values.image.tag}}"
imagePullPolicy: {{ .Values.global.imagePullPolicy }}
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
readOnlyRootFilesystem: false
privileged: false
command:
- fleet
args:
- cleanup
- gitjob
nodeSelector: {{ include "linux-node-selector" . | nindent 12 }}
tolerations: {{ include "linux-node-tolerations" . | nindent 12 }}
backoffLimit: 1
{{- end }}

0 comments on commit c3829bf

Please sign in to comment.