Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helm: add named template that creates the specification for a cronjob #701

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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