Passing large number of secrets/env variables to a docker executor run #21100
-
Hi, looking for guidance on how to pass a growing number of variables to a run launched with: run_launcher:
module: dagster_docker
class: DockerRunLauncher
config:
env_vars:
... Running Dagster 1.7 in OSS using docker. We have a growing number of environment variables to pull from for a variety of items, but we're running up to a problem where whenever we change the dagster.yaml to add these new variables to the run_launcher, we need to re-launch the daemon and ui container to capture these changes. If i recall these secrets are passed from the daemon to the container that is launched, so the environment variables need to be accessible on that container, and up to date, which leans better towards an external secrets provider. We have also tried swapping out the multiple variables with a single variable which connects to KeyVault, where the other ones sit. Our problem in this case is if we try to use the EnvVar approach, where it reads from the environment variables, we need to load all the secrets into the Am I missing the right way to inject secrets from an external place (keyvault, aws, etc.) using EnvVar, or is this approach to use the env var not valid in this case? We discussed moving the logic to pull the secret into the resources, but it feels like its creating a really tight link between the secrets provider and the resource, instead of the EnvVar approach where the resource pulls in the credentials as needed and is a more generalized. I see a few options:
Any suggestions on a preferred way forward? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Is the simple answer here that i should be defining every single variable as environment variables, then restarting all the containers whenever it changes? run_launcher:
module: dagster_docker
class: DockerRunLauncher
config:
env_vars:
- VAR1
- VAR2
- VAR3 certainly isn't as nice as just defining a single KeyVault token and connecting/pulling with that. |
Beta Was this translation helpful? Give feedback.
-
For closing this out we ended up doing the easy way of creating our own run launcher, subclassing the As a suggestion, if there was a config flag to |
Beta Was this translation helpful? Give feedback.
-
Even though this discussion is marked as closed, I wanted to share my experience because I frequently struggle with environment variable (EnvVar) resolution when using the In my view, placing all user-code-related variables in the The undocumented part is that you can specify a You can set this up using either the A method that has worked well for me is to standardize the names of environment variables relevant to Dagster pipelines with a generic prefix like env_vars=$(env | grep 'USER_CODE_' | xargs -I{} echo \"{}\" | paste -sd, - )
dagster api grpc -p 4000 -h 0.0.0.0 -m $USER_CODE_MODULE --container-context="{\"env_vars\": [$env_vars]}" This approach ensures that all I would also suggest to take a look at the helm chart of the k8s deployment option since also the k8s run launcher has the same issue and within the helm chart is resolved setting the container-context via the env variable |
Beta Was this translation helpful? Give feedback.
For closing this out we ended up doing the easy way of creating our own run launcher, subclassing the
DockerRunLauncher
. It basically just passes all but a few of the daemons environment variables over to the launched container. Has tradeoffs, but works great for us.As a suggestion, if there was a config flag to
pass_all_env_vars
this is basically what we did, so an option to do this would help.