Skip to content

Commit

Permalink
Pass schedules to emailer cronjobs from values.yaml (#1263)
Browse files Browse the repository at this point in the history
* Pass schedules to emailer cronjobs from values.yaml

* Add a comment to signify which dates correspond to which report
  • Loading branch information
Redande committed Jun 6, 2024
1 parent 45b3ffb commit b0e7011
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
12 changes: 7 additions & 5 deletions helm/templates/prague-stats-mailer-cronjob.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
{{- range $cron := .Values.cronjob.prague.crons }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: prague-stats-emailer
labels:
{{- include "helm.labels" . | nindent 4 }}
{{- include "helm.labels" $ | nindent 4 }}
spec:
# Run at 10:00 AM on 30th of November
schedule: "0 10 24 1 *"
schedule: "0 10 {{$cron.day}} {{$cron.month}} *"
startingDeadlineSeconds: 3600
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 3
jobTemplate:
metadata:
labels:
{{- include "helm.selectorLabels" . | nindent 8 }}
{{- include "helm.selectorLabels" $ | nindent 8 }}
spec:
activeDeadlineSeconds: 7200
template:
spec:
restartPolicy: OnFailure
containers:
- name: prague-stats-emailer
image: "{{ .Values.image.repository }}/moocfi-backend:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: "{{ $.Values.image.repository }}/moocfi-backend:{{ $.Values.image.tag | default $.Chart.AppVersion }}"
command: ["sh", "-c", "npm run prague-stats-emailer"]
envFrom:
- secretRef:
Expand All @@ -33,3 +34,4 @@ spec:
secretKeyRef:
name: new-redis
key: redis-password
{{- end }}
12 changes: 7 additions & 5 deletions helm/templates/purkyne-stats-mailer-cronjob.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
{{- range $cron := .Values.cronjob.purkyne.crons }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: purkyne-stats-emailer
labels:
{{- include "helm.labels" . | nindent 4 }}
{{- include "helm.labels" $ | nindent 4 }}
spec:
# Run at 10:00 AM on 30th of June
schedule: "0 10 30 6 *"
schedule: "0 10 {{$cron.day}} {{$cron.month}} *"
startingDeadlineSeconds: 3600
concurrencyPolicy: Forbid
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 3
jobTemplate:
metadata:
labels:
{{- include "helm.selectorLabels" . | nindent 8 }}
{{- include "helm.selectorLabels" $ | nindent 8 }}
spec:
activeDeadlineSeconds: 7200
template:
spec:
restartPolicy: OnFailure
containers:
- name: purkyne-stats-emailer
image: "{{ .Values.image.repository }}/moocfi-backend:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: "{{ $.Values.image.repository }}/moocfi-backend:{{ $.Values.image.tag | default $.Chart.AppVersion }}"
command: ["sh", "-c", "npm run purkyne-stats-emailer"]
envFrom:
- secretRef:
Expand All @@ -33,3 +34,4 @@ spec:
secretKeyRef:
name: new-redis
key: redis-password
{{- end }}
27 changes: 27 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,30 @@ nodeSelector: {}
tolerations: []

affinity: {}

cronjob:
prague: # @vse.cz report, see backend/bin/pragueStatsEmailer.ts
crons:
- id: "0"
day: 24
month: 1
- id: "1"
day: 31
month: 5
- id: "2"
day: 25
month: 8
- id: "3"
day: 29
month: 11
purkyne: # @ujep.cz report, see backend/bin/purkyneStatsEmailer.ts
crons:
- id: "0"
day: 30
month: 6
- id: "1"
day: 31
month: 8
- id: "2"
day: 20
month: 12

0 comments on commit b0e7011

Please sign in to comment.