From 4d8cca53940a480703757353bcc8caa9fb67cc64 Mon Sep 17 00:00:00 2001 From: Gabi Davar Date: Sat, 22 Jun 2024 20:00:30 +0300 Subject: [PATCH 1/2] Tell Go runtime about the CPU & memory limits. Signed-off-by: Gabi Davar --- .github/workflows/push.yaml | 2 +- .../chart/reloader/templates/deployment.yaml | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 3e9524c3e..fa4e95c77 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -215,7 +215,7 @@ jobs: --set reloader.deployment.resources.limits.cpu=150m \ --set reloader.deployment.resources.limits.memory=512Mi \ --set reloader.deployment.resources.requests.cpu=10m \ - --set reloader.deployment.resources.requests.memory=128Mi > deployments/kubernetes/reloader.yaml + --set reloader.deployment.resources.requests.memory=512Mi > deployments/kubernetes/reloader.yaml helm template reloader deployments/kubernetes/chart/reloader/ --output-dir deployments/kubernetes/manifests && mv deployments/kubernetes/manifests/reloader/templates/* deployments/kubernetes/manifests/ && rm -r deployments/kubernetes/manifests/reloader diff --git a/deployments/kubernetes/chart/reloader/templates/deployment.yaml b/deployments/kubernetes/chart/reloader/templates/deployment.yaml index e1105343b..7fcc3f9b7 100644 --- a/deployments/kubernetes/chart/reloader/templates/deployment.yaml +++ b/deployments/kubernetes/chart/reloader/templates/deployment.yaml @@ -76,8 +76,15 @@ spec: - image: "{{ .Values.reloader.deployment.image.name }}:{{ .Values.reloader.deployment.image.tag }}" imagePullPolicy: {{ .Values.reloader.deployment.image.pullPolicy }} name: {{ template "reloader-fullname" . }} - {{- if or (.Values.reloader.deployment.env.open) (.Values.reloader.deployment.env.secret) (.Values.reloader.deployment.env.field) (.Values.reloader.deployment.env.existing) (eq .Values.reloader.watchGlobally false) (.Values.reloader.enableHA) (.Values.reloader.enableMetricsByNamespace)}} env: + - name: GOMEMLIMIT + valueFrom: + resourceFieldRef: + resource: limits.memory + - name: GOMAXPROCS + valueFrom: + resourceFieldRef: + resource: limits.cpu {{- range $name, $value := .Values.reloader.deployment.env.open }} {{- if not (empty $value) }} - name: {{ $name | quote }} @@ -112,7 +119,6 @@ spec: fieldRef: fieldPath: {{ $value | quote}} {{- end }} - {{- end }} {{- if eq .Values.reloader.watchGlobally false }} - name: KUBERNETES_NAMESPACE valueFrom: From 36484c3005fb3da2deea00cc920a513f34fade14 Mon Sep 17 00:00:00 2001 From: Gabi Davar Date: Wed, 26 Jun 2024 10:10:53 +0300 Subject: [PATCH 2/2] review comments --- .github/workflows/push.yaml | 6 +++--- .../chart/reloader/templates/deployment.yaml | 13 ++++++++++--- deployments/kubernetes/chart/reloader/values.yaml | 5 +++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index fa4e95c77..a7a665aa2 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -212,10 +212,10 @@ jobs: - name: Helm Template run: | helm template reloader deployments/kubernetes/chart/reloader/ \ - --set reloader.deployment.resources.limits.cpu=150m \ - --set reloader.deployment.resources.limits.memory=512Mi \ + --set-string reloader.deployment.resources.limits.cpu=1 \ + --set reloader.deployment.resources.limits.memory=128Mi \ --set reloader.deployment.resources.requests.cpu=10m \ - --set reloader.deployment.resources.requests.memory=512Mi > deployments/kubernetes/reloader.yaml + --set reloader.deployment.resources.requests.memory=128Mi > deployments/kubernetes/reloader.yaml helm template reloader deployments/kubernetes/chart/reloader/ --output-dir deployments/kubernetes/manifests && mv deployments/kubernetes/manifests/reloader/templates/* deployments/kubernetes/manifests/ && rm -r deployments/kubernetes/manifests/reloader diff --git a/deployments/kubernetes/chart/reloader/templates/deployment.yaml b/deployments/kubernetes/chart/reloader/templates/deployment.yaml index 7fcc3f9b7..d43bd872b 100644 --- a/deployments/kubernetes/chart/reloader/templates/deployment.yaml +++ b/deployments/kubernetes/chart/reloader/templates/deployment.yaml @@ -77,14 +77,22 @@ spec: imagePullPolicy: {{ .Values.reloader.deployment.image.pullPolicy }} name: {{ template "reloader-fullname" . }} env: - - name: GOMEMLIMIT + - name: GOMAXPROCS + {{- if .Values.reloader.deployment.gomaxprocsOverride }} + value: {{ .Values.reloader.deployment.gomaxprocsOverride | quote }} + {{- else }} valueFrom: resourceFieldRef: resource: limits.memory - - name: GOMAXPROCS + {{- end }} + - name: GOMEMLIMIT + {{- if .Values.reloader.deployment.gomemlimitOverride }} + value: {{ .Values.reloader.deployment.gomemlimitOverride | quote }} + {{- else }} valueFrom: resourceFieldRef: resource: limits.cpu + {{- end }} {{- range $name, $value := .Values.reloader.deployment.env.open }} {{- if not (empty $value) }} - name: {{ $name | quote }} @@ -140,7 +148,6 @@ spec: value: enabled {{- end }} {{- end }} - ports: - name: http containerPort: 9090 diff --git a/deployments/kubernetes/chart/reloader/values.yaml b/deployments/kubernetes/chart/reloader/values.yaml index 20f9c6687..8f658ffcf 100644 --- a/deployments/kubernetes/chart/reloader/values.yaml +++ b/deployments/kubernetes/chart/reloader/values.yaml @@ -147,6 +147,11 @@ reloader: # imagePullSecrets: # - name: myregistrykey + # Put "0" in either to have go runtime ignore the set value. + # Otherwise, see https://pkg.go.dev/runtime#hdr-Environment_Variables for GOMAXPROCS and GOMEMLIMIT + gomaxprocsOverride: "" + gomemlimitOverride: "" + service: {} # labels: {} # annotations: {}