Skip to content

Commit 755bec0

Browse files
committed
feat(helm chart): Make env vars configurable and auto configure go runtime
Signed-off-by: Stevo Slavic <[email protected]>
1 parent 1cd2b2d commit 755bec0

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

charts/metrics-server/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
## [UNRELEASED]
1616

17+
### Added
18+
19+
- Extra environment variables configuration support.
20+
- Automatic container Go runtime (GOMAXPROCS, GOMEMLIMIT) configuration based on assigned resources, with opt-out support. ([#1412](https://github.com/kubernetes-sigs/metrics-server/pull/1412)) [@sslavic](https://github.com/sslavic)
21+
1722
## [3.12.0] - TBC
1823

1924
### Changed

charts/metrics-server/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ The following table lists the configurable parameters of the _Metrics Server_ ch
5454
| `podDisruptionBudget.maxUnavailable` | Set the `PodDisruptionBudget` maximum unavailable pods. | `nil` |
5555
| `defaultArgs` | Default arguments to pass to the _metrics-server_ command. | See _values.yaml_ |
5656
| `args` | Additional arguments to pass to the _metrics-server_ command. | `[]` |
57+
| `setAutoGoEnvVars` | Whether to automatically set GOMAXPROCS and GOMEMLIMIT env vars for all the containers. | `true` |
58+
| `extraEnvVars` | Additional environment variables to pass to the _metrics-server_ container. | `[]` |
5759
| `livenessProbe` | Liveness probe. | See _values.yaml_ |
5860
| `readinessProbe` | Readiness probe. | See _values.yaml_ |
5961
| `service.type` | Service type. | `ClusterIP` |
@@ -64,6 +66,7 @@ The following table lists the configurable parameters of the _Metrics Server_ ch
6466
| `addonResizer.securityContext` | Security context for the _metrics_server_container. | _See values.yaml |
6567
| `addonResizer.image.repository` | addon-resizer image repository | `registry.k8s.io/autoscaling/addon-resizer` |
6668
| `addonResizer.image.tag` | addon-resizer image tag | `1.8.19` |
69+
| `addonResizer.extraEnvVars` | Additional environment variables to pass to the _addon-resizer_ container. | `[]` |
6770
| `addonResizer.resources` | Resource requests and limits for the _nanny_ container. | `{ requests: { cpu: 40m, memory: 25Mi }, limits: { cpu: 40m, memory: 25Mi } }` |
6871
| `addonResizer.nanny.cpu` | The base CPU requirement. | `0m` |
6972
| `addonResizer.nanny.extraCPU` | The amount of CPU to add per node. | `1m` |

charts/metrics-server/templates/deployment.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ spec:
7272
{{- range .Values.args }}
7373
- {{ . }}
7474
{{- end }}
75+
env:
76+
{{- if .Values.setAutoGoEnvVars }}
77+
- name: GOMAXPROCS
78+
valueFrom:
79+
resourceFieldRef:
80+
resource: requests.cpu
81+
- name: GOMEMLIMIT
82+
valueFrom:
83+
resourceFieldRef:
84+
resource: limits.memory
85+
{{- end }}
86+
{{- with .Values.extraEnvVars }}
87+
{{- toYaml . | nindent 12 }}
88+
{{- end }}
7589
ports:
7690
- name: https
7791
protocol: TCP
@@ -110,6 +124,19 @@ spec:
110124
valueFrom:
111125
fieldRef:
112126
fieldPath: metadata.namespace
127+
{{- if .Values.setAutoGoEnvVars }}
128+
- name: GOMAXPROCS
129+
valueFrom:
130+
resourceFieldRef:
131+
resource: requests.cpu
132+
- name: GOMEMLIMIT
133+
valueFrom:
134+
resourceFieldRef:
135+
resource: limits.memory
136+
{{- end }}
137+
{{- with .Values.addonResizer.extraEnvVars }}
138+
{{- toYaml . | nindent 12 }}
139+
{{- end }}
113140
command:
114141
- /pod_nanny
115142
- --config-dir=/etc/config

charts/metrics-server/values.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ defaultArgs:
9898

9999
args: []
100100

101+
# Specifies whether to automatically set GOMAXPROCS and GOMEMLIMIT environment
102+
# variables for all containers relative to the assigned resources.
103+
setAutoGoEnvVars: true
104+
105+
extraEnvVars: []
106+
101107
livenessProbe:
102108
httpGet:
103109
path: /livez
@@ -130,6 +136,7 @@ addonResizer:
130136
image:
131137
repository: registry.k8s.io/autoscaling/addon-resizer
132138
tag: 1.8.20
139+
extraEnvVars: []
133140
securityContext:
134141
allowPrivilegeEscalation: false
135142
readOnlyRootFilesystem: true

0 commit comments

Comments
 (0)