Skip to content

Commit

Permalink
First pass at defining cron jobs in the values.yaml file.
Browse files Browse the repository at this point in the history
  • Loading branch information
ksuderman committed Feb 9, 2024
1 parent 4138130 commit e0b960d
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 24 deletions.
46 changes: 23 additions & 23 deletions galaxy/templates/cronjob-maintenance.yaml
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
{{ if .Values.cronJobs -}}
{{ range $key, $cronjob := .Values.cronJobs }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "galaxy.fullname" . }}-maintenance
name: {{ include "galaxy.fullname" $ }}-maintenance-{{ $key }}
labels:
{{- include "galaxy.labels" . | nindent 4 }}
{{- include "galaxy.labels" $ | nindent 4 }}
spec:
schedule: "0 2 * * *"
schedule: {{ $cronjob.schedule | quote }}
jobTemplate:
spec:
template:
spec:
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
{{- with .Values.nodeSelector }}
{{- toYaml $cronjob.securityContext | nindent 12 }}
{{- with $.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 16 }}
{{- end }}
containers:
- name: galaxy-maintenance
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
- name: galaxy-maintenance-{{ $key }}
image: "{{ $.Values.image.repository }}:{{ $.Values.image.tag }}"
imagePullPolicy: {{ $.Values.image.pullPolicy }}
# delete all tmp files older than walltime limit
command:
- find
- {{ .Values.persistence.mountPath }}/tmp
- '!'
- -newermt
- -{{ (index .Values "configs" "job_conf.yml" "runners" "k8s" "k8s_walltime_limit" | default 604800) }} seconds
- -type
- f
- -exec
- rm
- '{}'
- ;
command: {{ $cronjob.command }}
{{- if $cronjob.args }}
args:
{{- range $arg := $cronjob.args }}
- {{ tpl $arg $ }}
{{- end }}
{{- end }}
volumeMounts:
- name: galaxy-data
mountPath: {{ .Values.persistence.mountPath }}
mountPath: {{ $.Values.persistence.mountPath }}
volumes:
- name: galaxy-data
{{- if .Values.persistence.enabled }}
{{- if $.Values.persistence.enabled }}
persistentVolumeClaim:
claimName: {{ template "galaxy.pvcname" . }}
claimName: {{ template "galaxy.pvcname" $ }}
{{- else }}
emptyDir: {}
{{- end }}
restartPolicy: OnFailure
{{- end }}
{{- end }}
63 changes: 62 additions & 1 deletion galaxy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,66 @@ extraEnv: []
# - name: EXAMPLE_ENV
# value: MY_VALUE

cronJobs:
clean-tmp:
schedule: "0 2 * * *"
securityContext:
runAsUser: 0
command: /bin/bash
args:
- "-c"
- "find"
- "{{ .Values.persistence.mountPath }}/tmp"
- "!"
- "-newermt"
- "-{{ (index .Values \"configs\" \"job_conf.yml\" \"runners\" \"k8s\" \"k8s_walltime_limit\" | default 604800) }} seconds"
- "-type"
- "f"
- "-exec"
- "rm"
- "{}"
- ";"
clean-jobs:
schedule: "10 2 * * *"
securityContext:
runAsUser: 0
command: /usr/bin/tmpwatch
args:
- "-v"
- "--all"
- "--mtime"
- "--dirmtime"
- "7d"
- "{{ .Values.persistence.mountPath }}/jobs_directory"
cleanup-datasets:
schedule: "20 2 * * *"
securityContext:
runAsUser: 0
command: /galaxy/server/.venv/bin/python
args:
- "/galaxy/server/scripts/cleanup_datasets/pgcleanup.py"
- "-c"
- "/galaxy/server/config/galaxy.yml"
- "-o"
- "7"
- "-l"
- "{{ .Values.persistence.mountPath }}/tmp"
- "-w"
- "128MB"
- "delete_userless_histories"
- "delete_exported_histories"
cleanup-tusd-store:
schedule: "30 2 * * *"
securityContext:
runAsUser: 0
command: /usr/bin/tmpwatch
args:
- "-v"
- "--all"
- "--mtime"
- "--dirmtime"
- "7d"
- "{{ .Values.persistence.mountPath }}/tmp/tus_upload_store"
ingress:
#- Should ingress be enabled. Defaults to `true`
enabled: true
Expand Down Expand Up @@ -301,7 +361,8 @@ resources:
memory: 7G
ephemeral-storage: 10Gi

nodeSelector: {}
#nodeSelector: {}
nodeSelector: "cloud:google:com/gke-nodepool: default-pool"

tolerations: []

Expand Down

0 comments on commit e0b960d

Please sign in to comment.