Skip to content

Commit

Permalink
feat(helm chart): Make env vars configurable and auto configure go ru…
Browse files Browse the repository at this point in the history
…ntime

Signed-off-by: Stevo Slavic <sslavic@gmail.com>
  • Loading branch information
sslavic committed Jan 29, 2024
1 parent 1b01024 commit e8a8138
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions charts/metrics-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand All @@ -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` |
Expand Down
27 changes: 27 additions & 0 deletions charts/metrics-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions charts/metrics-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -130,6 +136,7 @@ addonResizer:
image:
repository: registry.k8s.io/autoscaling/addon-resizer
tag: 1.8.19
extraEnvVars: []
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
Expand Down

0 comments on commit e8a8138

Please sign in to comment.