Skip to content

Commit

Permalink
helm: add optional notifications
Browse files Browse the repository at this point in the history
* Useful to program system wide status reports with cronjobs
  (closes #308).
  • Loading branch information
Diego Rodriguez committed May 19, 2020
1 parent 4b36915 commit fc9084b
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 1 deletion.
10 changes: 9 additions & 1 deletion helm/reana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This Helm automatically prefixes all names using the release name to avoid colli

| Parameter | Description | Default value |
|----------------------------------------------------------|--------------------------------------------------------------------------------------|-------------------------------------------------|
| `components.reana_db.enabled` | Instantiate a PostgreSQL database inside the cluster | true |
| `components.reana_db.enabled` | Instantiate a PostgreSQL database inside the cluster | true |
| `components.reana_job_controller.image` | [REANA-Job-Controller image](https://hub.docker.com/repository/docker/reanahub/reana-job-controller) to use | `reanahub/reana-job-controller:<chart-release-verion>` |
| `components.reana_message_broker.image` | [REANA-Meessage-Broker image](https://hub.docker.com/repository/docker/reanahub/reana-message-broker) to use | `reanahub/reana-message-broker:<chart-release-verion>` |
| `components.reana_message_broker.imagePullPolicy` | REANA-Message-Broker image pull policy | IfNotPresent |
Expand All @@ -33,6 +33,14 @@ This Helm automatically prefixes all names using the release name to avoid colli
| `ingress.annotations.kubernetes.io/ingress.class` | Type of ingress controller | traefik |
| `ingress.annotations.traefik.frontend.entryPoints` | Entrypoints allowed by the ingress controller | "http,https" |
| `ingress.enabled` | Create an ingress resource to access the REANA instance from outside the cluster | true |
| `notifications.email_config.login` | Password for the sender email address | None |
| `notifications.email_config.password` | Login email address | None |
| `notifications.email_config.receiver` | Email address which will be receiving the notifications | None |
| `notifications.email_config.sender` | Email address which will be sending the notifications | None |
| `notifications.email_config.smtp_server` | SMTP email server host | None |
| `notifications.email_config.smtp_port` | SMTP email server port | None |
| `notifications.enabled` | Enable REANA system events notifications | false |
| `notifications.system_status` | Cronjob pattern representing how often the system status notification should be sent. Leave it empty to deactivate it | "0 0 * * *" |
| `secrets.cern.sso.CERN_CONSUMER_KEY` | CERN SSO consumer key | None |
| `secrets.cern.sso.CERN_CONSUMER_SECRET` | **[Do not use in production, use secrets instead]** CERN SSO consumer secret | None |
| `secrets.database.pasword` | **[Do not use in production, use secrets instead]** PostgreSQL database password | None |
Expand Down
83 changes: 83 additions & 0 deletions helm/reana/templates/cronjobs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{{- if .Values.notifications.enabled }}
{{- if .Values.notifications.system_status }}
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: {{ include "reana.prefix" . }}-system-status
spec:
schedule: {{ .Values.notifications.system_status }}
jobTemplate:
spec:
template:
spec:
containers:
- name: {{ include "reana.prefix" . }}-system-status
image: {{ .Values.components.reana_server.image }}
command:
- '/bin/sh'
- '-c'
args:
- 'flask reana-admin status-report --email {{ .Values.notifications.email_config.receiver }}'
{{- if .Values.debug.enabled }}
tty: true
stdin: true
{{- end }}
env:
{{- if .Values.debug.enabled }}
- name: REANA_EMAIL_SMTP_SERVER
value: {{ include "reana.prefix" . }}-mail
- name: REANA_EMAIL_SMTP_PORT
value: "30025"
- name: FLASK_ENV
value: "development"
{{- else }}
- name: REANA_EMAIL_SMTP_SERVER
value: {{ .Values.notifications.email_config.smtp_server }}
- name: REANA_SMTP_PORT
value: {{ .Values.notifications.email_config.smpt_port }}
- name: REANA_EMAIL_SENDER
value: {{ .Values.notifications.email_config.sender }}
- name: REANA_EMAIL_LOGIN
valueFrom:
secretKeyRef:
name: {{ include "reana.prefix" . }}-mail-notification-sender-password
key: REANA_EMAIL_LOGIN
- name: REANA_EMAIL_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "reana.prefix" . }}-mail-notification-sender-password
key: REANA_EMAIL_PASSWORD
{{- end }}
- name: REANA_COMPONENT_PREFIX
value: {{ include "reana.prefix" . }}
- name: REANA_EMAIL_SENDER
value: {{ .Values.notifications.email_config.sender }}
- name: REANA_ADMIN_ACCESS_TOKEN
valueFrom:
secretKeyRef:
name: {{ include "reana.prefix" . }}-admin-access-token
key: ADMIN_ACCESS_TOKEN
volumeMounts:
{{- if .Values.debug.enabled }}
- mountPath: /code/
name: reana-code
{{- end }}
- mountPath: {{ .Values.shared_storage.shared_volume_mount_path }}
name: reana-shared-volume
imagePullPolicy: IfNotPresent
restartPolicy: Never
volumes:
- name: reana-shared-volume
{{- if not (eq .Values.shared_storage.backend "hostpath") }}
persistentVolumeClaim:
claimName: {{ include "reana.prefix" . }}-shared-persistent-volume
readOnly: false
{{- else }}
hostPath:
path: {{ .Values.shared_storage.hostpath.root_path }}
{{- end }}
- name: reana-code
hostPath:
path: /code/reana-server
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions helm/reana/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,26 @@ data:
REANA_GITLAB_OAUTH_APP_ID: {{ .Values.secrets.gitlab.REANA_GITLAB_OAUTH_APP_ID | default "reana_gitlab_oauth_app_id" | b64enc }}
REANA_GITLAB_OAUTH_APP_SECRET: {{ .Values.secrets.gitlab.REANA_GITLAB_OAUTH_APP_SECRET | default "reana_gitlab_oauth_app_secret" | b64enc }}
REANA_GITLAB_HOST: {{ .Values.secrets.gitlab.REANA_GITLAB_HOST | default "gitlab.cern.ch" | b64enc }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ include "reana.prefix" . }}-admin-access-token
annotations:
"helm.sh/resource-policy": keep
type: Opaque
data:
ADMIN_ACCESS_TOKEN: {{ "aabbcc112233" | b64enc }}
{{- if and .Values.notifications.email_config.login .Values.notifications.email_config.password }}
---
apiVersion: v1
kind: Secret
metadata:
name: {{ include "reana.prefix" . }}-mail-notification-sender-password
annotations:
"helm.sh/resource-policy": keep
type: Opaque
data:
REANA_EMAIL_LOGIN: {{ .Values.notifications.email_config.login | b64enc }}
REANA_EMAIL_PASSWORD: {{ .Values.notifications.email_config.password | b64enc }}
{{- end }}
5 changes: 5 additions & 0 deletions helm/reana/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ components:
imagePullPolicy: IfNotPresent
image: reanahub/reana-ui:0.6.0-48-gbe42a5d

notifications:
enabled: false
email_config: {}
system_status: "0 0 * * *"

# Accessing the cluster from outside world
ingress:
enabled: true
Expand Down

0 comments on commit fc9084b

Please sign in to comment.