From 8c0f0774edf49eff0999f23d3ef512175f553269 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/README.md | 4 ++++ .../metrics-server/templates/deployment.yaml | 13 +++++++++++ charts/metrics-server/values.yaml | 22 +++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/charts/metrics-server/README.md b/charts/metrics-server/README.md index 0cbffc49e..00797ca63 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. | `[]` | +| `goEnvVars` | Go runtime environment variables to pass to the _metrics-server_ command. | See _values.yaml_ | +| `extraEnvVars` | Additional environment variables to pass to the _metrics-server_ command. | `[]` | | `livenessProbe` | Liveness probe. | See _values.yaml_ | | `readinessProbe` | Readiness probe. | See _values.yaml_ | | `service.type` | Service type. | `ClusterIP` | @@ -64,6 +66,8 @@ 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.goEnvVars` | Go runtime environment variables to pass to the _addon-resizer_ command. | See _values.yaml_ | +| `addonResizer.extraEnvVars` | Additional environment variables to pass to the _addon-resizer_ command. | `[]` | | `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..b1aebc16f 100644 --- a/charts/metrics-server/templates/deployment.yaml +++ b/charts/metrics-server/templates/deployment.yaml @@ -72,6 +72,13 @@ spec: {{- range .Values.args }} - {{ . }} {{- end }} + env: + {{- with .Values.goEnvVars }} + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.extraEnvVars }} + {{- toYaml . | nindent 12 }} + {{- end }} ports: - name: https protocol: TCP @@ -110,6 +117,12 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + {{- with .Values.addonResizer.goEnvVars }} + {{- toYaml . | nindent 12 }} + {{- 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 ae3712f5a..7ed7baf98 100644 --- a/charts/metrics-server/values.yaml +++ b/charts/metrics-server/values.yaml @@ -98,6 +98,18 @@ defaultArgs: args: [] +goEnvVars: + - name: GOMAXPROCS + valueFrom: + resourceFieldRef: + resource: requests.cpu + - name: GOMEMLIMIT + valueFrom: + resourceFieldRef: + resource: limits.memory + +extraEnvVars: [] + livenessProbe: httpGet: path: /livez @@ -130,6 +142,16 @@ addonResizer: image: repository: registry.k8s.io/autoscaling/addon-resizer tag: 1.8.19 + goEnvVars: + - name: GOMAXPROCS + valueFrom: + resourceFieldRef: + resource: requests.cpu + - name: GOMEMLIMIT + valueFrom: + resourceFieldRef: + resource: limits.memory + extraEnvVars: [] securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true