Skip to content

Commit

Permalink
helm: add named template that creates the specification for a cronjob
Browse files Browse the repository at this point in the history
  • Loading branch information
audrium committed Mar 3, 2023
1 parent 35f42c5 commit 7c454a3
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 328 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Version 0.9.1 (UNRELEASED)
- Adds support for Kubernetes clusters 1.26.
- Adds new configuration option ``ingress.extra`` to define extra Ingress resources, in order to support redirecting HTTP requests to HTTPS with traefik v2 version.
- Adds new configuration option ``ingress.tls.hosts`` to define hosts that are present in the TLS certificate, in order to support cert-manager's automatic creation of certificates.
- Developers:
- Adds Helm named template that creates the specification for a cronjob.

Version 0.9.0 (2023-01-26)
--------------------------
Expand Down
89 changes: 89 additions & 0 deletions helm/reana/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,92 @@ hostPath:
{{ template "reana.shared_volume" . }}
{{- end -}}
{{- end -}}

{{/* Create the specification of cronjob. */}}
{{- define "reana.cronjob_spec" -}}
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "reana.prefix" .scope }}-{{ .name }}
namespace: {{ .scope.Release.Namespace }}
spec:
schedule: {{ .schedule | quote }}
concurrencyPolicy: Forbid
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
{{- if .scope.Values.maintenance.enabled }}
suspend: true
{{- end }}
jobTemplate:
spec:
template:
spec:
serviceAccountName: {{ include "reana.prefixed_infrastructure_svaccount_name" .scope }}
containers:
- name: {{ include "reana.prefix" .scope }}-{{ .name }}
image: {{ .scope.Values.components.reana_server.image }}
command:
- '/bin/sh'
- '-c'
args:
{{- range .container_args }}
- {{ . | quote }}
{{- end }}
{{- if .scope.Values.debug.enabled }}
tty: true
stdin: true
{{- end }}
env:
{{- range $key, $value := .env_vars }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- range $key, $value := .env_vars_from_secret }}
- name: {{ $key }}
valueFrom:
secretKeyRef:
name: {{ first $value | quote }}
key: {{ last $value }}
{{- end }}
{{- range $key, $value := .scope.Values.db_env_config }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- if .scope.Values.debug.enabled }}
- name: FLASK_ENV
value: "development"
{{- else }}
- name: REANA_DB_USERNAME
valueFrom:
secretKeyRef:
name: {{ include "reana.prefix" .scope }}-db-secrets
key: user
- name: REANA_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "reana.prefix" .scope }}-db-secrets
key: password
{{- end }}
volumeMounts:
{{- if .scope.Values.debug.enabled }}
- mountPath: /code/
name: reana-code
{{- end }}
- mountPath: {{ .scope.Values.shared_storage.shared_volume_mount_path }}
name: reana-shared-volume
imagePullPolicy: IfNotPresent
restartPolicy: Never
volumes:
- name: reana-shared-volume
{{- if not (eq .scope.Values.shared_storage.backend "hostpath") }}
persistentVolumeClaim:
claimName: {{ include "reana.prefix" .scope }}-shared-persistent-volume
readOnly: false
{{- else }}
hostPath:
path: {{ .scope.Values.shared_storage.hostpath.root_path }}
{{- end }}
- name: reana-code
hostPath:
path: /code/reana-server
{{- end }}
Loading

0 comments on commit 7c454a3

Please sign in to comment.