From 478c6fc947b0d925f6bc65e0c85850fbff0d5f64 Mon Sep 17 00:00:00 2001 From: Pascal Sthamer Date: Mon, 1 Dec 2025 17:11:07 +0100 Subject: [PATCH] remove orborus-env configmap, add helpers for env variables Signed-off-by: Pascal Sthamer --- .../shuffle/templates/orborus/_helpers.tpl | 51 ++++++++++++ .../templates/orborus/orborus-cm-env.yaml | 82 ------------------- .../templates/orborus/orborus-dpl.yaml | 11 ++- .../templates/shuffle-app/_helpers.tpl | 10 +++ .../templates/shuffle-worker/_helpers.tpl | 52 ++++++++++++ .../shuffle-worker/shuffle-worker-dpl.yaml | 24 ++---- 6 files changed, 123 insertions(+), 107 deletions(-) delete mode 100644 functions/kubernetes/charts/shuffle/templates/orborus/orborus-cm-env.yaml diff --git a/functions/kubernetes/charts/shuffle/templates/orborus/_helpers.tpl b/functions/kubernetes/charts/shuffle/templates/orborus/_helpers.tpl index 3b3249b0..3ced6821 100644 --- a/functions/kubernetes/charts/shuffle/templates/orborus/_helpers.tpl +++ b/functions/kubernetes/charts/shuffle/templates/orborus/_helpers.tpl @@ -75,3 +75,54 @@ imagePullSecrets: {{- end }} {{- end }} {{- end -}} + +{{/* +Return the environment variables of shuffle-orborus in the format +KEY: VALUE +*/}} +{{- define "shuffle.orborus.env" -}} +RUNNING_MODE: kubernetes +IS_KUBERNETES: "true" +ENVIRONMENT_NAME: "{{ .Values.shuffle.org }}" +ORG_ID: "{{ .Values.shuffle.org }}" +TZ: "{{ .Values.shuffle.timezone }}" +BASE_URL: {{ include "shuffle.backend.baseUrl" . | quote }} +KUBERNETES_NAMESPACE: "{{ .Release.Namespace }}" +SHUFFLE_ORBORUS_EXECUTION_CONCURRENCY: {{ .Values.orborus.executionConcurrency | quote }} + +{{- if .Values.orborus.manageWorkerDeployments }} +# Shuffle worker configuration +SHUFFLE_WORKER_IMAGE: {{ include "shuffle.worker.image" . | quote }} +SHUFFLE_WORKER_SERVICE_ACCOUNT_NAME: {{ include "shuffle.worker.serviceAccount.name" . | quote }} +{{- if .Values.worker.podSecurityContext.enabled }} +SHUFFLE_WORKER_POD_SECURITY_CONTEXT: {{ omit .Values.worker.podSecurityContext "enabled" | mustToJson | quote }} +{{- end }} +{{- if .Values.worker.containerSecurityContext.enabled }} +SHUFFLE_WORKER_CONTAINER_SECURITY_CONTEXT: {{ include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.worker.containerSecurityContext "context" $) | fromYaml | mustToJson | quote }} +{{- end }} + +# Shuffle worker resources +{{- $workerResources := (.Values.worker.resources | default (include "common.resources.preset" (dict "type" .Values.worker.resourcesPreset) | fromYaml)) -}} +{{- if and $workerResources.requests $workerResources.requests.cpu }} +SHUFFLE_WORKER_CPU_REQUEST: {{ $workerResources.requests.cpu | quote }} +{{- end }} +{{- if and $workerResources.requests $workerResources.requests.memory}} +SHUFFLE_WORKER_MEMORY_REQUEST: {{ $workerResources.requests.memory | quote }} +{{- end }} +{{- if and $workerResources.requests (index $workerResources.requests "ephemeral-storage") }} +SHUFFLE_WORKER_EPHEMERAL_STORAGE_REQUEST: {{ (index $workerResources.requests "ephemeral-storage") | quote }} +{{- end }} +{{- if and $workerResources.limits $workerResources.limits.cpu }} +SHUFFLE_WORKER_CPU_LIMIT: {{ $workerResources.limits.cpu | quote }} +{{- end }} +{{- if and $workerResources.limits $workerResources.limits.memory}} +SHUFFLE_WORKER_MEMORY_LIMIT: {{ $workerResources.limits.memory | quote }} +{{- end }} +{{- if and $workerResources.limits (index $workerResources.limits "ephemeral-storage") }} +SHUFFLE_WORKER_EPHEMERAL_STORAGE_LIMIT: {{ (index $workerResources.limits "ephemeral-storage") | quote }} +{{- end }} + +# Include shuffle worker environment variables. Orborus passes them down to worker, when creating the deployment. +{{ include "shuffle.workerInstance.env" . }} +{{- end }} +{{- end -}} \ No newline at end of file diff --git a/functions/kubernetes/charts/shuffle/templates/orborus/orborus-cm-env.yaml b/functions/kubernetes/charts/shuffle/templates/orborus/orborus-cm-env.yaml deleted file mode 100644 index 4ce584bd..00000000 --- a/functions/kubernetes/charts/shuffle/templates/orborus/orborus-cm-env.yaml +++ /dev/null @@ -1,82 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: {{ include "shuffle.orborus.name" . }}-env - namespace: {{ include "common.names.namespace" . | quote }} - labels: {{- include "shuffle.orborus.labels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }} - {{- if .Values.commonAnnotations }} - annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }} - {{- end }} -data: - ENVIRONMENT_NAME: "{{ .Values.shuffle.org }}" - ORG_ID: "{{ .Values.shuffle.org }}" - TZ: "{{ .Values.shuffle.timezone }}" - BASE_URL: {{ import "shuffle.backend.baseUrl" . | quote }} - KUBERNETES_NAMESPACE: "{{ .Release.Namespace }}" - REGISTRY_URL: "{{ .Values.shuffle.appRegistry }}" - - {{- if .Values.orborus.manageWorkerDeployments }} - # Shuffle worker configuration - SHUFFLE_WORKER_IMAGE: {{ include "shuffle.worker.image" . | quote }} - SHUFFLE_WORKER_SERVICE_ACCOUNT_NAME: {{ include "shuffle.worker.serviceAccount.name" . | quote }} - {{- if .Values.worker.podSecurityContext.enabled }} - SHUFFLE_WORKER_POD_SECURITY_CONTEXT: {{ omit .Values.worker.podSecurityContext "enabled" | mustToJson | quote }} - {{- end }} - {{- if .Values.worker.containerSecurityContext.enabled }} - SHUFFLE_WORKER_CONTAINER_SECURITY_CONTEXT: {{ include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.worker.containerSecurityContext "context" $) | fromYaml | mustToJson | quote }} - {{- end }} - - # Shuffle worker resources - {{- $workerResources := (.Values.worker.resources | default (include "common.resources.preset" (dict "type" .Values.worker.resourcesPreset) | fromYaml)) -}} - {{- if and $workerResources.requests $workerResources.requests.cpu }} - SHUFFLE_WORKER_CPU_REQUEST: {{ $workerResources.requests.cpu | quote }} - {{- end }} - {{- if and $workerResources.requests $workerResources.requests.memory}} - SHUFFLE_WORKER_MEMORY_REQUEST: {{ $workerResources.requests.memory | quote }} - {{- end }} - {{- if and $workerResources.requests (index $workerResources.requests "ephemeral-storage") }} - SHUFFLE_WORKER_EPHEMERAL_STORAGE_REQUEST: {{ (index $workerResources.requests "ephemeral-storage") | quote }} - {{- end }} - {{- if and $workerResources.limits $workerResources.limits.cpu }} - SHUFFLE_WORKER_CPU_LIMIT: {{ $workerResources.limits.cpu | quote }} - {{- end }} - {{- if and $workerResources.limits $workerResources.limits.memory}} - SHUFFLE_WORKER_MEMORY_LIMIT: {{ $workerResources.limits.memory | quote }} - {{- end }} - {{- if and $workerResources.limits (index $workerResources.limits "ephemeral-storage") }} - SHUFFLE_WORKER_EPHEMERAL_STORAGE_LIMIT: {{ (index $workerResources.limits "ephemeral-storage") | quote }} - {{- end }} - - {{- if .Values.worker.manageAppDeployments }} - # Shuffle app configuration - SHUFFLE_APP_EXPOSED_PORT: {{ .Values.app.exposedContainerPort | quote }} - SHUFFLE_APP_SERVICE_ACCOUNT_NAME: {{ include "shuffle.app.serviceAccount.name" . | quote }} - {{- if .Values.app.podSecurityContext.enabled }} - SHUFFLE_APP_POD_SECURITY_CONTEXT: {{ omit .Values.app.podSecurityContext "enabled" | mustToJson | quote }} - {{- end }} - {{- if .Values.app.containerSecurityContext.enabled }} - SHUFFLE_APP_CONTAINER_SECURITY_CONTEXT: {{ include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.app.containerSecurityContext "context" $) | fromYaml | mustToJson | quote }} - {{- end }} - - # Shuffle app resources - {{- $appResources := (.Values.app.resources | default (include "common.resources.preset" (dict "type" .Values.app.resourcesPreset) | fromYaml)) -}} - {{- if and $appResources.requests $appResources.requests.cpu }} - SHUFFLE_APP_CPU_REQUEST: {{ $appResources.requests.cpu | quote }} - {{- end }} - {{- if and $appResources.requests $appResources.requests.memory }} - SHUFFLE_APP_MEMORY_REQUEST: {{ $appResources.requests.memory | quote }} - {{- end }} - {{- if and $appResources.requests (index $appResources.requests "ephemeral-storage") }} - SHUFFLE_APP_EPHEMERAL_STORAGE_REQUEST: {{ (index $appResources.requests "ephemeral-storage") | quote }} - {{- end }} - {{- if and $appResources.limits $appResources.limits.cpu }} - SHUFFLE_APP_CPU_LIMIT: {{ $appResources.limits.cpu | quote }} - {{- end }} - {{- if and $appResources.limits $appResources.limits.memory }} - SHUFFLE_APP_MEMORY_LIMIT: {{ $appResources.limits.memory | quote }} - {{- end }} - {{- if and $appResources.limits (index $appResources.limits "ephemeral-storage") }} - SHUFFLE_APP_EPHEMERAL_STORAGE_LIMIT: {{ (index $appResources.limits "ephemeral-storage") | quote }} - {{- end }} - {{- end }} - {{- end }} diff --git a/functions/kubernetes/charts/shuffle/templates/orborus/orborus-dpl.yaml b/functions/kubernetes/charts/shuffle/templates/orborus/orborus-dpl.yaml index a786dcd2..88f19bed 100644 --- a/functions/kubernetes/charts/shuffle/templates/orborus/orborus-dpl.yaml +++ b/functions/kubernetes/charts/shuffle/templates/orborus/orborus-dpl.yaml @@ -82,16 +82,15 @@ spec: args: {{- include "common.tplvalues.render" (dict "value" .Values.orborus.args "context" $) | nindent 12 }} {{- end }} env: - - name: RUNNING_MODE - value: kubernetes - - name: IS_KUBERNETES - value: "true" + {{- $env := include "shuffle.orborus.env" . | fromYaml }} + {{- range $key, $val := $env }} + - name: {{ $key | quote }} + value: {{ $val | quote }} + {{- end }} {{- if .Values.orborus.extraEnvVars }} {{- include "common.tplvalues.render" (dict "value" .Values.orborus.extraEnvVars "context" $) | nindent 12 }} {{- end }} envFrom: - - configMapRef: - name: {{ include "shuffle.orborus.name" . }}-env {{- if .Values.orborus.extraEnvVarsCM }} - configMapRef: name: {{ include "common.tplvalues.render" (dict "value" .Values.orborus.extraEnvVarsCM "context" $) }} diff --git a/functions/kubernetes/charts/shuffle/templates/shuffle-app/_helpers.tpl b/functions/kubernetes/charts/shuffle/templates/shuffle-app/_helpers.tpl index 533c9dde..4a482335 100644 --- a/functions/kubernetes/charts/shuffle/templates/shuffle-app/_helpers.tpl +++ b/functions/kubernetes/charts/shuffle/templates/shuffle-app/_helpers.tpl @@ -100,3 +100,13 @@ as well as worker-deployed apps (deployK8sApp). {{- define "shuffle.appInstance.matchLabels" -}} app.kubernetes.io/name: shuffle-app {{- end -}} + +{{/* +Return the environment variables of shuffle apps in the format +KEY: VALUE +*/}} +{{- define "shuffle.appInstance.env" -}} +SHUFFLE_APP_SDK_TIMEOUT: {{ .Values.app.sdkTimeout | quote }} +SHUFFLE_APP_EXPOSED_PORT: {{ .Values.app.exposedContainerPort | quote }} +SHUFFLE_LOGS_DISABLED: {{ .Values.app.disableLogs | quote }} +{{- end -}} diff --git a/functions/kubernetes/charts/shuffle/templates/shuffle-worker/_helpers.tpl b/functions/kubernetes/charts/shuffle/templates/shuffle-worker/_helpers.tpl index 5a165ffa..4ac59321 100644 --- a/functions/kubernetes/charts/shuffle/templates/shuffle-worker/_helpers.tpl +++ b/functions/kubernetes/charts/shuffle/templates/shuffle-worker/_helpers.tpl @@ -89,3 +89,55 @@ as well as orborus-deployed workers (deployk8sworker). {{- define "shuffle.workerInstance.matchLabels" -}} app.kubernetes.io/name: shuffle-worker {{- end -}} + +{{/* +Return the environment variables of shuffle-worker in the format +KEY: VALUE +*/}} +{{- define "shuffle.workerInstance.env" -}} +IS_KUBERNETES: "true" +KUBERNETES_NAMESPACE: "{{ .Release.Namespace }}" +BASE_URL: {{ include "shuffle.backend.baseUrl" . | quote }} +SHUFFLE_APP_EXPOSED_PORT: {{ .Values.app.exposedContainerPort | quote }} +WORKER_HOSTNAME: "{{ include "shuffle.worker.name" . }}.{{ .Release.Namespace }}.svc.cluster.local" + +{{- if .Values.worker.manageAppDeployments }} +# Shuffle app images +REGISTRY_URL: "{{ .Values.shuffle.appRegistry }}" +SHUFFLE_BASE_IMAGE_REGISTRY: "{{ .Values.shuffle.appRegistry }}" +SHUFFLE_BASE_IMAGE_NAME: "{{ .Values.shuffle.appBaseImageName }}" + +# Shuffle app deployment configuration +SHUFFLE_APP_SERVICE_ACCOUNT_NAME: {{ include "shuffle.app.serviceAccount.name" . | quote }} +{{- if .Values.app.podSecurityContext.enabled }} +SHUFFLE_APP_POD_SECURITY_CONTEXT: {{ omit .Values.app.podSecurityContext "enabled" | mustToJson | quote }} +{{- end }} +{{- if .Values.app.containerSecurityContext.enabled }} +SHUFFLE_APP_CONTAINER_SECURITY_CONTEXT: {{ include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.app.containerSecurityContext "context" $) | fromYaml | mustToJson | quote }} +{{- end }} + +# Shuffle app resources +{{- $appResources := (.Values.app.resources | default (include "common.resources.preset" (dict "type" .Values.app.resourcesPreset) | fromYaml)) -}} +{{- if and $appResources.requests $appResources.requests.cpu }} +SHUFFLE_APP_CPU_REQUEST: {{ $appResources.requests.cpu | quote }} +{{- end }} +{{- if and $appResources.requests $appResources.requests.memory }} +SHUFFLE_APP_MEMORY_REQUEST: {{ $appResources.requests.memory | quote }} +{{- end }} +{{- if and $appResources.requests (index $appResources.requests "ephemeral-storage") }} +SHUFFLE_APP_EPHEMERAL_STORAGE_REQUEST: {{ (index $appResources.requests "ephemeral-storage") | quote }} +{{- end }} +{{- if and $appResources.limits $appResources.limits.cpu }} +SHUFFLE_APP_CPU_LIMIT: {{ $appResources.limits.cpu | quote }} +{{- end }} +{{- if and $appResources.limits $appResources.limits.memory }} +SHUFFLE_APP_MEMORY_LIMIT: {{ $appResources.limits.memory | quote }} +{{- end }} +{{- if and $appResources.limits (index $appResources.limits "ephemeral-storage") }} +SHUFFLE_APP_EPHEMERAL_STORAGE_LIMIT: {{ (index $appResources.limits "ephemeral-storage") | quote }} +{{- end }} + +# Include shuffle app environment variables. Worker passes them down to apps, when creating their deployment. +{{ include "shuffle.appInstance.env" . }} +{{- end }} +{{- end -}} \ No newline at end of file diff --git a/functions/kubernetes/charts/shuffle/templates/shuffle-worker/shuffle-worker-dpl.yaml b/functions/kubernetes/charts/shuffle/templates/shuffle-worker/shuffle-worker-dpl.yaml index 1832991c..09d00269 100644 --- a/functions/kubernetes/charts/shuffle/templates/shuffle-worker/shuffle-worker-dpl.yaml +++ b/functions/kubernetes/charts/shuffle/templates/shuffle-worker/shuffle-worker-dpl.yaml @@ -83,25 +83,11 @@ spec: args: {{- include "common.tplvalues.render" (dict "value" .Values.worker.args "context" $) | nindent 12 }} {{- end }} env: - - name: IS_KUBERNETES - value: "true" - - name: KUBERNETES_NAMESPACE - value: "{{ .Release.Namespace }}" - - name: SHUFFLE_LOGS_DISABLED - value: "false" # TODO: Allow to configure. Share with orborus / apps? - - name: BASE_URL - value: {{ import "shuffle.backend.baseUrl" . | quote }} - - name: REGISTRY_URL # TODO: REGISTRY_URL vs. SHUFFLE_BASE_IMAGE_REGISTRY - value: {{ .Values.shuffle.appRegistry }} - - name: SHUFFLE_BASE_IMAGE_REGISTRY - value: {{ .Values.shuffle.appRegistry }} - - name: SHUFFLE_BASE_IMAGE_NAME - value: shuffle # TODO: Allow to configure? Use same as for orborus (shared value) - - name: SHUFFLE_APP_EXPOSED_PORT - value: {{ .Values.app.exposedContainerPort | quote }} - - name: WORKER_HOSTNAME - value: {{ include "shuffle.worker.name" }}.{{ .Release.Namespace }}.svc.cluster.local - # TODO: If manageAppDeployments is set, we need to add some variables! + {{- $env := include "shuffle.workerInstance.env" . | fromYaml }} + {{- range $key, $val := $env }} + - name: {{ $key | quote }} + value: {{ $val | quote }} + {{- end }} {{- if .Values.worker.extraEnvVars }} {{- include "common.tplvalues.render" (dict "value" .Values.worker.extraEnvVars "context" $) | nindent 12 }} {{- end }}