Skip to content

Commit

Permalink
Add extraEnvVarsCMs for multiple ConfigMaps
Browse files Browse the repository at this point in the history
Adds support for definining multiple ConfigMaps in the Worker
Deployment.

Related to #421
  • Loading branch information
mitchnielsen committed Jan 9, 2025
1 parent 04b1fbc commit 921fc95
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 3 deletions.
3 changes: 2 additions & 1 deletion charts/prefect-worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ worker:
| worker.extraArgs | list | `[]` | array with extra Arguments for the worker container to start with |
| worker.extraContainers | list | `[]` | additional sidecar containers |
| worker.extraEnvVars | list | `[]` | array with extra environment variables to add to worker nodes |
| worker.extraEnvVarsCM | string | `""` | name of existing ConfigMap containing extra env vars to add to worker nodes |
| worker.extraEnvVarsCM | string | `""` | name of existing ConfigMap containing extra env vars to add to worker nodes (deprecated, use extraEnvVarsCMs) |
| worker.extraEnvVarsCMs | list | `[]` | names of existing ConfigMaps containing extra env vars to add to worker nodes |
| worker.extraEnvVarsSecret | string | `""` | name of existing Secret containing extra env vars to add to worker nodes |
| worker.extraVolumeMounts | list | `[]` | array with extra volumeMounts for the worker pod |
| worker.extraVolumes | list | `[]` | array with extra volumes for the worker pod |
Expand Down
4 changes: 4 additions & 0 deletions charts/prefect-worker/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ spec:
- configMapRef:
name: {{ include "common.tplvalues.render" (dict "value" .Values.worker.extraEnvVarsCM "context" $) }}
{{- end }}
{{- range .Values.worker.extraEnvVarsCMs }}
- configMapRef:
name: {{ include "common.tplvalues.render" (dict "value" . "context" $) }}
{{- end }}
{{- if .Values.worker.extraEnvVarsSecret }}
- secretRef:
name: {{ include "common.tplvalues.render" (dict "value" .Values.worker.extraEnvVarsSecret "context" $) }}
Expand Down
20 changes: 20 additions & 0 deletions charts/prefect-worker/tests/worker_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,26 @@ tests:
path: .spec.template.spec.containers[0].envFrom[0].configMapRef.name
value: my-config-map

- it: Should set extra environment variables from ConfigMaps
set:
worker:
extraEnvVarsCMs:
- my-config-map
- my-other-config-map
asserts:
- template: deployment.yaml
contains:
path: .spec.template.spec.containers[0].envFrom
content:
configMapRef:
name: my-config-map
- template: deployment.yaml
contains:
path: .spec.template.spec.containers[0].envFrom
content:
configMapRef:
name: my-other-config-map

- it: Should set extra volumes
set:
worker:
Expand Down
7 changes: 6 additions & 1 deletion charts/prefect-worker/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,12 @@
"extraEnvVarsCM": {
"type": "string",
"title": "Extra Env Vars ConfigMap",
"description": "name of existing ConfigMap containing extra env vars to add to worker nodes"
"description": "name of existing ConfigMap containing extra env vars to add to worker nodes (deprecated, use extraEnvVarsCMs)"
},
"extraEnvVarsCMs": {
"type": "array",
"title": "Extra Env Vars ConfigMaps",
"description": "names of existing ConfigMaps containing extra env vars to add to worker nodes"
},
"extraEnvVarsSecret": {
"type": "string",
Expand Down
5 changes: 4 additions & 1 deletion charts/prefect-worker/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,12 @@ worker:
# -- array with extra environment variables to add to worker nodes
extraEnvVars: []

# -- name of existing ConfigMap containing extra env vars to add to worker nodes
# -- name of existing ConfigMap containing extra env vars to add to worker nodes (deprecated, use extraEnvVarsCMs)
extraEnvVarsCM: ""

# -- names of existing ConfigMaps containing extra env vars to add to worker nodes
extraEnvVarsCMs: []

# -- name of existing Secret containing extra env vars to add to worker nodes
extraEnvVarsSecret: ""

Expand Down

0 comments on commit 921fc95

Please sign in to comment.