Skip to content

Commit

Permalink
Tell Go runtime about the CPU & memory limits. (#699)
Browse files Browse the repository at this point in the history
* Tell Go runtime about the CPU & memory limits.

Signed-off-by: Gabi Davar <grizzly.nyo@gmail.com>

* review comments

---------

Signed-off-by: Gabi Davar <grizzly.nyo@gmail.com>
  • Loading branch information
mindw authored Aug 7, 2024
1 parent 4dceccc commit 12b9a19
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ 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=128Mi > deployments/kubernetes/reloader.yaml
Expand Down
19 changes: 16 additions & 3 deletions deployments/kubernetes/chart/reloader/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,23 @@ 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: GOMAXPROCS
{{- if .Values.reloader.deployment.gomaxprocsOverride }}
value: {{ .Values.reloader.deployment.gomaxprocsOverride | quote }}
{{- else }}
valueFrom:
resourceFieldRef:
resource: limits.memory
{{- 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 }}
Expand Down Expand Up @@ -112,7 +127,6 @@ spec:
fieldRef:
fieldPath: {{ $value | quote}}
{{- end }}
{{- end }}
{{- if eq .Values.reloader.watchGlobally false }}
- name: KUBERNETES_NAMESPACE
valueFrom:
Expand All @@ -134,7 +148,6 @@ spec:
value: enabled
{{- end }}
{{- end }}

ports:
- name: http
containerPort: 9090
Expand Down
5 changes: 5 additions & 0 deletions deployments/kubernetes/chart/reloader/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down

0 comments on commit 12b9a19

Please sign in to comment.