chore(crons): Adding generator for new cron jobs

This commit is contained in:
rjshrjndrn 2024-07-09 13:09:34 +02:00
parent 124b4ab506
commit 6a7b55452a
5 changed files with 67 additions and 429 deletions

View file

@ -1,4 +1,8 @@
{{- if .Values.global.enterpriseEditionLicense }}
{{- $context := . }}
{{- range $key, $job := .Values.apiCrons }}
{{- with $context }}
---
{{- $kubeTargetVersion := .Capabilities.KubeVersion.GitVersion }}
{{- if semverCompare ">=1.22.0-0" $kubeTargetVersion }}
apiVersion: batch/v1
@ -7,10 +11,10 @@ apiVersion: batch/v1beta1
{{- end }}
kind: CronJob
metadata:
name: report-cron
name: {{$key | kebabcase}}-cron
namespace: {{ .Release.Namespace }}
spec:
schedule: "{{ .Values.report.cron }}"
schedule: "{{ $job.cron }}"
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 1
jobTemplate:
@ -38,8 +42,8 @@ spec:
{{- end }}
containers:
- name: report-cron
image: "{{ tpl .Values.report.image.repository . }}:{{ .Values.report.image.tag | default .Chart.AppVersion }}-ee"
imagePullPolicy: "{{ .Values.report.image.pullPolicy}}"
image: "{{ tpl $job.image.repository . }}:{{ $job.image.tag | default .Chart.AppVersion }}-ee"
imagePullPolicy: "{{ $job.image.pullPolicy}}"
env:
{{- range $key, $val := .Values.global.env }}
- name: {{ $key }}
@ -116,8 +120,10 @@ spec:
value: '{{ .Values.global.email.emailSslCert }}'
- name: EMAIL_FROM
value: '{{ .Values.global.email.emailFrom }}'
{{- range $key, $val := .Values.report.env }}
{{- range $key, $val := $job.env }}
- name: {{ $key }}
value: '{{ $val }}'
{{- end}}
{{- end}}
{{- end}}
{{- end}}

View file

@ -1,123 +0,0 @@
{{- if .Values.global.enterpriseEditionLicense }}
{{- $kubeTargetVersion := .Capabilities.KubeVersion.GitVersion }}
{{- if semverCompare ">=1.22.0-0" $kubeTargetVersion }}
apiVersion: batch/v1
{{- else }}
apiVersion: batch/v1beta1
{{- end }}
kind: CronJob
metadata:
name: assiststats-cron
namespace: {{ .Release.Namespace }}
spec:
schedule: "{{ .Values.assiststats.cron }}"
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 1
jobTemplate:
spec:
backoffLimit: 0 # Don't restart the failed jobs
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 12 }}
{{- end }}
spec:
restartPolicy: Never
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 12 }}
{{- end }}
containers:
- name: assiststats-cron
image: "{{ tpl .Values.assiststats.image.repository . }}:{{ .Values.assiststats.image.tag | default .Chart.AppVersion }}-ee"
imagePullPolicy: {{ .Values.assiststats.image.pullPolicy }}
env:
{{- range $key, $val := .Values.global.env }}
- name: {{ $key }}
value: '{{ $val }}'
{{- end }}
- name: LICENSE_KEY
value: '{{ .Values.global.enterpriseEditionLicense }}'
- name: version_number
value: '{{ .Chart.AppVersion }}'
- name: pg_host
value: '{{ .Values.global.postgresql.postgresqlHost }}'
- name: pg_port
value: "5432"
- name: pg_dbname
value: "{{ .Values.global.postgresql.postgresqlDatabase }}"
- name: pg_user
value: '{{ .Values.global.postgresql.postgresqlUser }}'
- name: pg_password
{{- if .Values.global.postgresql.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.global.postgresql.existingSecret }}
key: postgresql-postgres-password
{{- else }}
value: '{{ .Values.global.postgresql.postgresqlPassword }}'
{{- end}}
- name: SITE_URL
value: '{{- include "openreplay.domainURL" . }}'
- name: S3_HOST
value: '{{- include "openreplay.s3Endpoint" . }}'
- name: S3_KEY
{{- if .Values.global.s3.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.global.s3.existingSecret }}
key: access-key
{{- else }}
value: {{ .Values.global.s3.accessKey }}
{{- end }}
- name: S3_SECRET
{{- if .Values.global.s3.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.global.s3.existingSecret }}
key: secret-key
{{- else }}
value: {{ .Values.global.s3.secretKey }}
{{- end }}
- name: AWS_DEFAULT_REGION
value: '{{ .Values.global.s3.region }}'
- name: sessions_region
value: '{{ .Values.global.s3.region }}'
- name: sessions_bucket
value: {{ .Values.global.s3.recordingsBucket }}
- name: sourcemaps_bucket
value: {{ .Values.global.s3.sourcemapsBucket }}
- name: js_cache_bucket
value: {{ .Values.global.s3.assetsBucket }}
- name: EMAIL_HOST
value: '{{ .Values.global.email.emailHost }}'
- name: EMAIL_PORT
value: '{{ .Values.global.email.emailPort }}'
- name: EMAIL_USER
value: '{{ .Values.global.email.emailUser }}'
- name: EMAIL_PASSWORD
value: '{{ .Values.global.email.emailPassword }}'
- name: EMAIL_USE_TLS
value: '{{ .Values.global.email.emailUseTls }}'
- name: EMAIL_USE_SSL
value: '{{ .Values.global.email.emailUseSsl }}'
- name: EMAIL_SSL_KEY
value: '{{ .Values.global.email.emailSslKey }}'
- name: EMAIL_SSL_CERT
value: '{{ .Values.global.email.emailSslCert }}'
- name: EMAIL_FROM
value: '{{ .Values.global.email.emailFrom }}'
{{- range $key, $val := .Values.assiststats.env }}
- name: {{ $key }}
value: '{{ $val }}'
{{- end}}
{{- end}}

View file

@ -1,123 +0,0 @@
{{- if .Values.global.enterpriseEditionLicense }}
{{- $kubeTargetVersion := .Capabilities.KubeVersion.GitVersion }}
{{- if semverCompare ">=1.22.0-0" $kubeTargetVersion }}
apiVersion: batch/v1
{{- else }}
apiVersion: batch/v1beta1
{{- end }}
kind: CronJob
metadata:
name: sessions-cleaner-cron
namespace: {{ .Release.Namespace }}
spec:
schedule: "{{ .Values.sessionsCleaner.cron }}"
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 1
jobTemplate:
spec:
backoffLimit: 0 # Don't restart the failed jobs
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 12 }}
{{- end }}
spec:
restartPolicy: Never
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 12 }}
{{- end }}
containers:
- name: sessions-cleaner-cron
image: "{{ tpl .Values.sessionsCleaner.image.repository . }}:{{ .Values.sessionsCleaner.image.tag | default .Chart.AppVersion }}-ee"
imagePullPolicy: {{ .Values.sessionsCleaner.image.pullPolicy }}
env:
{{- range $key, $val := .Values.global.env }}
- name: {{ $key }}
value: '{{ $val }}'
{{- end }}
- name: LICENSE_KEY
value: '{{ .Values.global.enterpriseEditionLicense }}'
- name: version_number
value: '{{ .Chart.AppVersion }}'
- name: pg_host
value: '{{ .Values.global.postgresql.postgresqlHost }}'
- name: pg_port
value: "5432"
- name: pg_dbname
value: "{{ .Values.global.postgresql.postgresqlDatabase }}"
- name: pg_user
value: '{{ .Values.global.postgresql.postgresqlUser }}'
- name: pg_password
{{- if .Values.global.postgresql.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.global.postgresql.existingSecret }}
key: postgresql-postgres-password
{{- else }}
value: '{{ .Values.global.postgresql.postgresqlPassword }}'
{{- end}}
- name: SITE_URL
value: '{{- include "openreplay.domainURL" . }}'
- name: S3_HOST
value: '{{- include "openreplay.s3Endpoint" . }}'
- name: S3_KEY
{{- if .Values.global.s3.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.global.s3.existingSecret }}
key: access-key
{{- else }}
value: {{ .Values.global.s3.accessKey }}
{{- end }}
- name: S3_SECRET
{{- if .Values.global.s3.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.global.s3.existingSecret }}
key: secret-key
{{- else }}
value: {{ .Values.global.s3.secretKey }}
{{- end }}
- name: AWS_DEFAULT_REGION
value: '{{ .Values.global.s3.region }}'
- name: sessions_region
value: '{{ .Values.global.s3.region }}'
- name: sessions_bucket
value: {{ .Values.global.s3.recordingsBucket }}
- name: sourcemaps_bucket
value: {{ .Values.global.s3.sourcemapsBucket }}
- name: js_cache_bucket
value: {{ .Values.global.s3.assetsBucket }}
- name: EMAIL_HOST
value: '{{ .Values.global.email.emailHost }}'
- name: EMAIL_PORT
value: '{{ .Values.global.email.emailPort }}'
- name: EMAIL_USER
value: '{{ .Values.global.email.emailUser }}'
- name: EMAIL_PASSWORD
value: '{{ .Values.global.email.emailPassword }}'
- name: EMAIL_USE_TLS
value: '{{ .Values.global.email.emailUseTls }}'
- name: EMAIL_USE_SSL
value: '{{ .Values.global.email.emailUseSsl }}'
- name: EMAIL_SSL_KEY
value: '{{ .Values.global.email.emailSslKey }}'
- name: EMAIL_SSL_CERT
value: '{{ .Values.global.email.emailSslCert }}'
- name: EMAIL_FROM
value: '{{ .Values.global.email.emailFrom }}'
{{- range $key, $val := .Values.sessionsCleaner.env }}
- name: {{ $key }}
value: '{{ $val }}'
{{- end}}
{{- end}}

View file

@ -1,123 +0,0 @@
{{- if .Values.global.enterpriseEditionLicense }}
{{- $kubeTargetVersion := .Capabilities.KubeVersion.GitVersion }}
{{- if semverCompare ">=1.22.0-0" $kubeTargetVersion }}
apiVersion: batch/v1
{{- else }}
apiVersion: batch/v1beta1
{{- end }}
kind: CronJob
metadata:
name: telemetry-cron
namespace: {{ .Release.Namespace }}
spec:
schedule: "{{ .Values.telemetry.cron }}"
failedJobsHistoryLimit: 1
successfulJobsHistoryLimit: 1
jobTemplate:
spec:
backoffLimit: 0 # Don't restart the failed jobs
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 12 }}
{{- end }}
spec:
restartPolicy: Never
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 12 }}
{{- end }}
containers:
- name: telemetry-cron
image: "{{ tpl .Values.telemetry.image.repository . }}:{{ .Values.telemetry.image.tag | default .Chart.AppVersion }}-ee"
imagePullPolicy: {{ .Values.telemetry.image.pullPolicy }}
env:
{{- range $key, $val := .Values.global.env }}
- name: {{ $key }}
value: '{{ $val }}'
{{- end }}
- name: LICENSE_KEY
value: '{{ .Values.global.enterpriseEditionLicense }}'
- name: version_number
value: '{{ .Chart.AppVersion }}'
- name: pg_host
value: '{{ .Values.global.postgresql.postgresqlHost }}'
- name: pg_port
value: "5432"
- name: pg_dbname
value: "{{ .Values.global.postgresql.postgresqlDatabase }}"
- name: pg_user
value: '{{ .Values.global.postgresql.postgresqlUser }}'
- name: pg_password
{{- if .Values.global.postgresql.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.global.postgresql.existingSecret }}
key: postgresql-postgres-password
{{- else }}
value: '{{ .Values.global.postgresql.postgresqlPassword }}'
{{- end}}
- name: SITE_URL
value: '{{- include "openreplay.domainURL" . }}'
- name: S3_HOST
value: '{{- include "openreplay.s3Endpoint" . }}'
- name: S3_KEY
{{- if .Values.global.s3.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.global.s3.existingSecret }}
key: access-key
{{- else }}
value: {{ .Values.global.s3.accessKey }}
{{- end }}
- name: S3_SECRET
{{- if .Values.global.s3.existingSecret }}
valueFrom:
secretKeyRef:
name: {{ .Values.global.s3.existingSecret }}
key: secret-key
{{- else }}
value: {{ .Values.global.s3.secretKey }}
{{- end }}
- name: AWS_DEFAULT_REGION
value: '{{ .Values.global.s3.region }}'
- name: sessions_region
value: '{{ .Values.global.s3.region }}'
- name: sessions_bucket
value: {{ .Values.global.s3.recordingsBucket }}
- name: sourcemaps_bucket
value: {{ .Values.global.s3.sourcemapsBucket }}
- name: js_cache_bucket
value: {{ .Values.global.s3.assetsBucket }}
- name: EMAIL_HOST
value: '{{ .Values.global.email.emailHost }}'
- name: EMAIL_PORT
value: '{{ .Values.global.email.emailPort }}'
- name: EMAIL_USER
value: '{{ .Values.global.email.emailUser }}'
- name: EMAIL_PASSWORD
value: '{{ .Values.global.email.emailPassword }}'
- name: EMAIL_USE_TLS
value: '{{ .Values.global.email.emailUseTls }}'
- name: EMAIL_USE_SSL
value: '{{ .Values.global.email.emailUseSsl }}'
- name: EMAIL_SSL_KEY
value: '{{ .Values.global.email.emailSslKey }}'
- name: EMAIL_SSL_CERT
value: '{{ .Values.global.email.emailSslCert }}'
- name: EMAIL_FROM
value: '{{ .Values.global.email.emailFrom }}'
{{- range $key, $val := .Values.telemetry.env }}
- name: {{ $key }}
value: '{{ $val }}'
{{- end}}
{{- end}}

View file

@ -28,61 +28,62 @@ telemetry:
env:
ACTION: "TELEMETRY"
assiststats:
# https://crontab.guru/#5_12_*_*_*
# Midnight 12.05
cron: "0 * * * *"
image:
repository: "{{ .Values.global.openReplayContainerRegistry }}/crons"
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: ""
env:
ACTION: "ASSIST_STATS"
report:
# https://crontab.guru/#0_5_*_*_1
# Monday morning 5am
cron: "0 5 * * 1"
image:
repository: "{{ .Values.global.openReplayContainerRegistry }}/crons"
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: ""
env:
ACTION: "REPORT"
sessionsCleaner:
# https://crontab.guru/#5_1_*_*_*
# Midnight 1.05
cron: "5 1 * * *"
image:
repository: "{{ .Values.global.openReplayContainerRegistry }}/crons"
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: ""
env:
ACTION: "JOB"
projectsStats:
# https://crontab.guru/#*/18_*_*_*_*
# Every 18 min
cron: "*/18 * * * *"
image:
repository: "{{ .Values.global.openReplayContainerRegistry }}/crons"
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: ""
env:
ACTION: "PROJECTS_STATS"
fixProjectsStats:
# https://crontab.guru/#0_5_*_*_0
# Sunday at 5am
cron: "0 5 * * 0"
image:
repository: "{{ .Values.global.openReplayContainerRegistry }}/crons"
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: ""
env:
ACTION: "FIX_PROJECTS_STATS"
apiCrons:
assiststats:
# https://crontab.guru/#5_12_*_*_*
# Midnight 12.05
cron: "0 * * * *"
image:
repository: "{{ .Values.global.openReplayContainerRegistry }}/crons"
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: ""
env:
ACTION: "ASSIST_STATS"
report:
# https://crontab.guru/#0_5_*_*_1
# Monday morning 5am
cron: "0 5 * * 1"
image:
repository: "{{ .Values.global.openReplayContainerRegistry }}/crons"
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: ""
env:
ACTION: "REPORT"
sessionsCleaner:
# https://crontab.guru/#5_1_*_*_*
# Midnight 1.05
cron: "5 1 * * *"
image:
repository: "{{ .Values.global.openReplayContainerRegistry }}/crons"
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: ""
env:
ACTION: "JOB"
projectsStats:
# https://crontab.guru/#*/18_*_*_*_*
# Every 18 min
cron: "*/18 * * * *"
image:
repository: "{{ .Values.global.openReplayContainerRegistry }}/crons"
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: ""
env:
ACTION: "PROJECTS_STATS"
fixProjectsStats:
# https://crontab.guru/#0_5_*_*_0
# Sunday at 5am
cron: "0 5 * * 0"
image:
repository: "{{ .Values.global.openReplayContainerRegistry }}/crons"
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: ""
env:
ACTION: "FIX_PROJECTS_STATS"
# Common env values are from chalice for the crons
chalice: