From 755bec0fd7e5d0376ed122e78215d117cb522532 Mon Sep 17 00:00:00 2001 From: Stevo Slavic Date: Fri, 26 Jan 2024 12:51:31 +0100 Subject: [PATCH] feat(helm chart): Make env vars configurable and auto configure go runtime Signed-off-by: Stevo Slavic --- charts/metrics-server/CHANGELOG.md | 5 ++++ charts/metrics-server/README.md | 3 +++ .../metrics-server/templates/deployment.yaml | 27 +++++++++++++++++++ charts/metrics-server/values.yaml | 7 +++++ 4 files changed, 42 insertions(+) diff --git a/charts/metrics-server/CHANGELOG.md b/charts/metrics-server/CHANGELOG.md index a14d16a07..ecf428394 100644 --- a/charts/metrics-server/CHANGELOG.md +++ b/charts/metrics-server/CHANGELOG.md @@ -14,6 +14,11 @@ ## [UNRELEASED] +### Added + +- Extra environment variables configuration support. +- 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) + ## [3.12.0] - TBC ### Changed diff --git a/charts/metrics-server/README.md b/charts/metrics-server/README.md index 0cbffc49e..8cf5a0506 100644 --- a/charts/metrics-server/README.md +++ b/charts/metrics-server/README.md @@ -54,6 +54,8 @@ The following table lists the configurable parameters of the _Metrics Server_ ch | `podDisruptionBudget.maxUnavailable` | Set the `PodDisruptionBudget` maximum unavailable pods. | `nil` | | `defaultArgs` | Default arguments to pass to the _metrics-server_ command. | See _values.yaml_ | | `args` | Additional arguments to pass to the _metrics-server_ command. | `[]` | +| `setAutoGoEnvVars` | Whether to automatically set GOMAXPROCS and GOMEMLIMIT env vars for all the containers. | `true` | +| `extraEnvVars` | Additional environment variables to pass to the _metrics-server_ container. | `[]` | | `livenessProbe` | Liveness probe. | See _values.yaml_ | | `readinessProbe` | Readiness probe. | See _values.yaml_ | | `service.type` | Service type. | `ClusterIP` | @@ -64,6 +66,7 @@ The following table lists the configurable parameters of the _Metrics Server_ ch | `addonResizer.securityContext` | Security context for the _metrics_server_container. | _See values.yaml | | `addonResizer.image.repository` | addon-resizer image repository | `registry.k8s.io/autoscaling/addon-resizer` | | `addonResizer.image.tag` | addon-resizer image tag | `1.8.19` | +| `addonResizer.extraEnvVars` | Additional environment variables to pass to the _addon-resizer_ container. | `[]` | | `addonResizer.resources` | Resource requests and limits for the _nanny_ container. | `{ requests: { cpu: 40m, memory: 25Mi }, limits: { cpu: 40m, memory: 25Mi } }` | | `addonResizer.nanny.cpu` | The base CPU requirement. | `0m` | | `addonResizer.nanny.extraCPU` | The amount of CPU to add per node. | `1m` | diff --git a/charts/metrics-server/templates/deployment.yaml b/charts/metrics-server/templates/deployment.yaml index 48cda7feb..d04a0e714 100644 --- a/charts/metrics-server/templates/deployment.yaml +++ b/charts/metrics-server/templates/deployment.yaml @@ -72,6 +72,20 @@ spec: {{- range .Values.args }} - {{ . }} {{- end }} + env: + {{- if .Values.setAutoGoEnvVars }} + - name: GOMAXPROCS + valueFrom: + resourceFieldRef: + resource: requests.cpu + - name: GOMEMLIMIT + valueFrom: + resourceFieldRef: + resource: limits.memory + {{- end }} + {{- with .Values.extraEnvVars }} + {{- toYaml . | nindent 12 }} + {{- end }} ports: - name: https protocol: TCP @@ -110,6 +124,19 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + {{- if .Values.setAutoGoEnvVars }} + - name: GOMAXPROCS + valueFrom: + resourceFieldRef: + resource: requests.cpu + - name: GOMEMLIMIT + valueFrom: + resourceFieldRef: + resource: limits.memory + {{- end }} + {{- with .Values.addonResizer.extraEnvVars }} + {{- toYaml . | nindent 12 }} + {{- end }} command: - /pod_nanny - --config-dir=/etc/config diff --git a/charts/metrics-server/values.yaml b/charts/metrics-server/values.yaml index 4f6b9219b..e1b80dfa9 100644 --- a/charts/metrics-server/values.yaml +++ b/charts/metrics-server/values.yaml @@ -98,6 +98,12 @@ defaultArgs: args: [] +# Specifies whether to automatically set GOMAXPROCS and GOMEMLIMIT environment +# variables for all containers relative to the assigned resources. +setAutoGoEnvVars: true + +extraEnvVars: [] + livenessProbe: httpGet: path: /livez @@ -130,6 +136,7 @@ addonResizer: image: repository: registry.k8s.io/autoscaling/addon-resizer tag: 1.8.20 + extraEnvVars: [] securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true