Skip to content

Commit

Permalink
feat(podtemplate): set GOMEMLIMIT, GOMAXPROCS when limits are defined
Browse files Browse the repository at this point in the history
  • Loading branch information
ChandonPierre committed Apr 6, 2024
1 parent d57d4a9 commit fed2873
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
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
24 changes: 24 additions & 0 deletions traefik/tests/pod-config_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@ 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 env with specified values
set:
env:
Expand Down

0 comments on commit fed2873

Please sign in to comment.