Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(podtemplate): set GOMEMLIMIT, GOMAXPROCS when limits are defined #1029

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions traefik/templates/_podtemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,18 @@
{{- end }}
{{- with .Values.env }}
env:
{{- if ($.Values.resources.limits).cpu }}
- name: GOMAXPROCS
valueFrom:
resourceFieldRef:
resource: limits.cpu
{{- end }}
{{- if ($.Values.resources.limits).memory }}
- name: GOMEMLIMIT
valueFrom:
resourceFieldRef:
resource: limits.memory
{{- end }}
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.envFrom }}
Expand Down
34 changes: 34 additions & 0 deletions traefik/tests/pod-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,40 @@ capabilities:
majorVersion: 1
minorVersion: 16
tests:
- it: should have set GOMAXPROCS with cpu limit
set:
resources:
limits:
cpu: "4"
asserts:
- equal:
path: spec.template.spec.containers[0].env[0].name
value: GOMAXPROCS
- equal:
path: spec.template.spec.containers[0].env[0].valueFrom.resourceFieldRef.resource
value: limits.cpu
- it: should have set GOMEMLIMIT with cpu limit
set:
resources:
limits:
memory: "4"
asserts:
- equal:
path: spec.template.spec.containers[0].env[0].name
value: GOMEMLIMIT
- equal:
path: spec.template.spec.containers[0].env[0].valueFrom.resourceFieldRef.resource
value: limits.memory
- it: should have not set GOMAXPROCS without cpu limit
asserts:
- notEqual:
path: spec.template.spec.containers[0].env[0].name
value: GOMAXPROCS
- it: should have not set GOMEMLIMIT without cpu limit
asserts:
- notEqual:
path: spec.template.spec.containers[0].env[0].name
value: GOMEMLIMIT
- it: should have env with specified values
set:
env:
Expand Down