Skip to content

Commit

Permalink
templates: add optional runtime namespace
Browse files Browse the repository at this point in the history
* Allows having two different namespaces for infrastructure and runtime
  pods (closes #268).
  • Loading branch information
Diego Rodriguez committed Jun 11, 2020
1 parent ab838ca commit 824b347
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 8 deletions.
2 changes: 2 additions & 0 deletions helm/reana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ This Helm automatically prefixes all names using the release name to avoid colli
| `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 * * *" |
| `reana_url` | REANA URL host | None |
| `default_runtime_namespace` | Namespace in which the REANA runtime pods (workflow engines, jobs etc...) will run | None |
| `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
6 changes: 6 additions & 0 deletions helm/reana/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ naming spec: `my-reana-batch-yadage-3c640169-d3b7-41ad-9c09-392c903fc1d8`
{{- define "reana.prefixed_svaccount_name" -}}
{{- include "reana.prefix" . -}}-{{- .Values.serviceAccount.name -}}
{{- end -}}
{{- define "reana.prefixed_infrastructure_svaccount_name" -}}
{{- include "reana.prefixed_svaccount_name" . -}}-infrastructure
{{- end -}}
{{- define "reana.prefixed_runtime_svaccount_name" -}}
{{- include "reana.prefixed_svaccount_name" . -}}-runtime
{{- end -}}
10 changes: 9 additions & 1 deletion helm/reana/templates/reana-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
labels:
app: {{ include "reana.prefix" . }}-server
spec:
serviceAccountName: {{ include "reana.prefixed_svaccount_name" . }}
serviceAccountName: {{ include "reana.prefixed_infrastructure_svaccount_name" . }}
containers:
- name: rest-api
image: {{ .Values.components.reana_server.image }}
Expand Down Expand Up @@ -58,6 +58,10 @@ spec:
env:
- name: REANA_COMPONENT_PREFIX
value: {{ include "reana.prefix" . }}
- name: REANA_INFRASTRUCTURE_KUBERNETES_NAMESPACE
value: {{ .Release.Namespace }}
- name: REANA_RUNTIME_KUBERNETES_NAMESPACE
value: {{ .Values.default_runtime_namespace | default .Release.Namespace }}
{{- range $key, $value := .Values.db_env_config }}
- name: {{ $key }}
value: {{ $value | quote }}
Expand Down Expand Up @@ -169,6 +173,10 @@ spec:
env:
- name: REANA_COMPONENT_PREFIX
value: {{ include "reana.prefix" . }}
- name: REANA_INFRASTRUCTURE_KUBERNETES_NAMESPACE
value: {{ .Release.Namespace }}
- name: REANA_RUNTIME_KUBERNETES_NAMESPACE
value: {{ .Values.default_runtime_namespace | default .Release.Namespace }}
{{- range $key, $value := .Values.db_env_config }}
- name: {{ $key }}
value: {{ $value | quote }}
Expand Down
18 changes: 13 additions & 5 deletions helm/reana/templates/reana-workflow-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
labels:
app: {{ include "reana.prefix" . }}-workflow-controller
spec:
serviceAccountName: {{ include "reana.prefixed_svaccount_name" . }}
serviceAccountName: {{ include "reana.prefixed_infrastructure_svaccount_name" . }}
containers:
- name: rest-api
image: {{ .Values.components.reana_workflow_controller.image }}
Expand All @@ -53,8 +53,10 @@ spec:
env:
- name: REANA_COMPONENT_PREFIX
value: {{ include "reana.prefix" . }}
- name: REANA_KUBERNETES_NAMESPACE
- name: REANA_INFRASTRUCTURE_KUBERNETES_NAMESPACE
value: {{ .Release.Namespace }}
- name: REANA_RUNTIME_KUBERNETES_NAMESPACE
value: {{ .Values.default_runtime_namespace | default .Release.Namespace }}
{{- if .Values.naming_scheme }}
- name: REANA_COMPONENT_NAMING_SCHEME
value: {{ .Values.naming_scheme }}
Expand All @@ -67,8 +69,12 @@ spec:
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
- name: K8S_REANA_SERVICE_ACCOUNT_NAME
value: {{ include "reana.prefixed_svaccount_name" . }}
- name: REANA_INFRASTRUCTURE_KUBERNETES_SERVICEACCOUNT_NAME
value: {{ include "reana.prefixed_infrastructure_svaccount_name" . }}
{{- if .Values.default_runtime_namespace }}
- name: REANA_RUNTIME_KUBERNETES_SERVICEACCOUNT_NAME
value: {{ include "reana.prefixed_runtime_svaccount_name" . }}
{{- end }}
- name: REANA_JOB_CONTROLLER_IMAGE
value: {{ .Values.components.reana_job_controller.image }}
- name: REANA_WORKFLOW_ENGINE_IMAGE_CWL
Expand Down Expand Up @@ -137,8 +143,10 @@ spec:
env:
- name: REANA_COMPONENT_PREFIX
value: {{ include "reana.prefix" . }}
- name: REANA_KUBERNETES_NAMESPACE
- name: REANA_INFRASTRUCTURE_KUBERNETES_NAMESPACE
value: {{ .Release.Namespace }}
- name: REANA_RUNTIME_KUBERNETES_NAMESPACE
value: {{ .Values.default_runtime_namespace | default .Release.Namespace }}
{{- range $key, $value := .Values.db_env_config }}
- name: {{ $key }}
value: {{ $value | quote }}
Expand Down
7 changes: 6 additions & 1 deletion helm/reana/templates/roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,10 @@ roleRef:
name: {{ include "reana.prefix" . }}-deployment-manager
subjects:
- kind: ServiceAccount
name: {{ include "reana.prefixed_svaccount_name" . }}
name: {{ include "reana.prefixed_infrastructure_svaccount_name" . }}
namespace: {{ .Release.Namespace }}
{{- if .Values.default_runtime_namespace }}
- kind: ServiceAccount
name: {{ include "reana.prefixed_runtime_svaccount_name" . }}
namespace: {{ .Values.default_runtime_namespace }}
{{- end }}
16 changes: 15 additions & 1 deletion helm/reana/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "reana.prefixed_svaccount_name" . }}
name: {{ include "reana.prefixed_infrastructure_svaccount_name" . }}
namespace: {{ .Release.Namespace }}
{{- if .Values.default_runtime_namespace }}
---
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.default_runtime_namespace }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "reana.prefixed_runtime_svaccount_name" . }}
namespace: {{ .Values.default_runtime_namespace }}
{{- end }}

0 comments on commit 824b347

Please sign in to comment.