Skip to content

Commit

Permalink
Add extraEnvVarsSecrets for multiple Secrets
Browse files Browse the repository at this point in the history
Adds support for defining multiple Secrets in the Worker Deployment.

Related to #421
  • Loading branch information
mitchnielsen committed Jan 9, 2025
1 parent 921fc95 commit 65dbdd6
Show file tree
Hide file tree
Showing 5 changed files with 48 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 @@ -310,7 +310,8 @@ worker:
| 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 (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.extraEnvVarsSecret | string | `""` | name of existing Secret containing extra env vars to add to worker nodes (deprecated, use extraEnvVarsSecrets) |
| worker.extraEnvVarsSecrets | list | `[]` | names of existing Secrets 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 |
| worker.image.debug | bool | `false` | enable worker image debug mode |
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 @@ -217,6 +217,10 @@ spec:
- secretRef:
name: {{ include "common.tplvalues.render" (dict "value" .Values.worker.extraEnvVarsSecret "context" $) }}
{{- end }}
{{- range .Values.worker.extraEnvVarsSecrets }}
- secretRef:
name: {{ include "common.tplvalues.render" (dict "value" . "context" $) }}
{{- end }}
{{- if .Values.worker.resources }}
resources: {{- toYaml .Values.worker.resources | nindent 12 }}
{{- end }}
Expand Down
32 changes: 32 additions & 0 deletions charts/prefect-worker/tests/worker_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,38 @@ tests:
configMapRef:
name: my-other-config-map

- it: Should set extra environment variables from Secret
set:
worker:
extraEnvVarsSecret: my-secret
asserts:
- template: deployment.yaml
contains:
path: .spec.template.spec.containers[0].envFrom
content:
secretRef:
name: my-secret

- it: Should set extra environment variables from Secrets
set:
worker:
extraEnvVarsSecrets:
- my-secret
- my-other-secret
asserts:
- template: deployment.yaml
contains:
path: .spec.template.spec.containers[0].envFrom
content:
secretRef:
name: my-secret
- template: deployment.yaml
contains:
path: .spec.template.spec.containers[0].envFrom
content:
secretRef:
name: my-other-secret

- 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 @@ -631,7 +631,12 @@
"extraEnvVarsSecret": {
"type": "string",
"title": "Extra Env Vars Secret",
"description": "name of existing Secret containing extra env vars to add to worker nodes"
"description": "name of existing Secret containing extra env vars to add to worker nodes (deprecated, use extraEnvVarsSecrets)"
},
"extraEnvVarsSecrets": {
"type": "array",
"title": "Extra Env Vars Secrets",
"description": "names of existing Secrets containing extra env vars to add to worker nodes"
},
"extraContainers": {
"type": "array",
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 @@ -258,9 +258,12 @@ worker:
# -- 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
# -- name of existing Secret containing extra env vars to add to worker nodes (deprecated, use extraEnvVarsSecrets)
extraEnvVarsSecret: ""

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

# -- additional sidecar containers
extraContainers: []

Expand Down

0 comments on commit 65dbdd6

Please sign in to comment.