-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleanup jobs back to cronjob (#2952)
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
Showing
1 changed file
with
36 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |