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 9, 2024
1 parent 2252aba commit e4f2aa8
Show file tree
Hide file tree
Showing 2 changed files with 46 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
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

0 comments on commit e4f2aa8

Please sign in to comment.