Skip to content

Commit

Permalink
feat: Define cron jobs running mgmt commands in Helm chart (#440)
Browse files Browse the repository at this point in the history
* feat: Define cron jobs running mgmt commands in Helm chart

* chore: Use UTC for cron jobs

* chore: Prevent cron jobs from overlapping

* chore: Disable retries on failed jobs
  • Loading branch information
microamp authored May 15, 2024
1 parent e07f9cb commit 35525ce
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 1 deletion.
42 changes: 42 additions & 0 deletions helm/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{{- range .Values.cronjob.crons }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ .name | quote }}
spec:
schedule: {{ .schedule | quote }}
timeZone: {{ .timeZone | quote }}
concurrencyPolicy: Forbid
jobTemplate:
spec:
backoffLimit: 0 # No retries
template:
spec:
restartPolicy: Never
volumes:
- name: settings-local-volume
configMap:
name: django-configmap
containers:
- name: {{ .name | quote }}
image: "{{ .image.repository }}:{{ default $.Chart.AppVersion .image.tag }}"
imagePullPolicy: {{ .image.pullPolicy }}
volumeMounts:
- name: settings-local-volume
mountPath: /app/ietf/settings/local.py
subPath: local.py
readOnly: true
{{- if $.Values.env }}
env:
- name: "POD_IP"
valueFrom:
fieldRef:
fieldPath: status.podIP
{{- range $key, $val := $.Values.env }}
- name: {{ $key | quote }}
value: {{ $val | quote }}
{{- end }}
{{- end }}
command: {{ .command | toJson }}
{{- end }}
25 changes: 24 additions & 1 deletion helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ wagtail:
repository: "ghcr.io/ietf-tools/www"
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
# tag: "v2.1.3"
# tag: "v2.1.10"

imagePullSecrets: []
nameOverride: ""
Expand Down Expand Up @@ -199,6 +199,29 @@ memcached:

affinity: {}

# -------------------------------------------------------------
# SCHEDULED JOBS
# -------------------------------------------------------------

cronjob:
crons:
- name: mgmt-hourly
schedule: "0 * * * *" # "At minute 0."
timeZone: "Etc/UTC"
image:
repository: "ghcr.io/ietf-tools/www"
pullPolicy: IfNotPresent
# tag: "v2.1.10"
command: ["python", "/app/manage.py", "publish_scheduled"]
- name: mgmt-weekly
schedule: "30 0 * * 0" # "At 00:30 on Sunday."
timeZone: "Etc/UTC"
image:
repository: "ghcr.io/ietf-tools/www"
pullPolicy: IfNotPresent
# tag: "v2.1.10"
command: ["python", "/app/manage.py", "update_index"]

# -------------------------------------------------------------
# COMMON
# -------------------------------------------------------------
Expand Down

0 comments on commit 35525ce

Please sign in to comment.