automatically set GOMEMLIMIT env variable

Signed-off-by: Pascal Sthamer <pascal+github@sthamer.xyz>
This commit is contained in:
Pascal Sthamer
2026-04-07 13:00:49 +02:00
parent 1279bb0949
commit d07ef7376a
8 changed files with 104 additions and 9 deletions
@@ -131,17 +131,15 @@ http://shuffle-workers.{{ .Release.Namespace }}.svc.cluster.local
{{/*
Return the environment variables of shuffle-worker in the format
KEY: VALUE
WARNING: Do NOT add environment variables here that would conflict with shuffle.orborus.env.
Orborus also sets all env variables that are defined here, because they will be passed down to worker when orborus.manageWorkerDeployments is set.
Instead, add them directly to the deployment template (shuffle-worker-dpl.yaml).
*/}}
{{- define "shuffle.workerInstance.env" -}}
IS_KUBERNETES: "true"
KUBERNETES_NAMESPACE: "{{ .Release.Namespace }}"
SHUFFLE_SWARM_CONFIG: "run" # Shuffle Worker requires this to be set even when using K8s instead of swarm
BASE_URL: {{ include "shuffle.backend.baseUrl" . | quote }}
SHUFFLE_APP_EXPOSED_PORT: {{ .Values.app.exposedContainerPort | quote }}
WORKER_HOSTNAME: {{ include "shuffle.worker.hostname" . }}
{{- if .Values.worker.debug }}
DEBUG: "true"
{{- end }}
{{- if .Values.worker.manageAppDeployments }}
# Shuffle app images
@@ -85,6 +85,23 @@ spec:
env:
- name: CLEANUP
value: "false" # Do not remove resources when restarting worker
- name: IS_KUBERNETES
value: "true"
- name: KUBERNETES_NAMESPACE
value: {{ .Release.Namespace | quote }}
- name: BASE_URL
value: {{ include "shuffle.backend.baseUrl" . | quote }}
{{- if .Values.worker.debug }}
- name: DEBUG
value: "true"
{{- end }}
{{- if .Values.worker.autoGOMEMLIMIT }}
{{- $workerResources := (.Values.worker.resources | default (include "common.resources.preset" (dict "type" .Values.worker.resourcesPreset) | fromYaml)) -}}
{{- if and $workerResources $workerResources.limits $workerResources.limits.memory }}
- name: GOMEMLIMIT
value: {{ include "shuffle.k8sMemoryLimitToGOMEMLIMIT" (dict "k8sMemoryLimit" $workerResources.limits.memory) | quote }}
{{- end }}
{{- end }}
{{- $env := include "shuffle.workerInstance.env" . | fromYaml }}
{{- range $key, $val := $env }}
- name: {{ $key | quote }}