Lukas N.

12/16/2020, 9:55 AM
Hi Prefect community 👋, I've got a problem with passing environment variables from Kubernetes agent to DaskKubernetesEnvironment. Anyone able to help? More in thread
My setup is a Kubernetes agent started with the
--env FOO=BAR
option. I'm able to spawn "regular" flows as jobs just fine and it will also pass the env variables (as seen here). Now I would like to test out the DaskKubernetesEnvironment and access the
env variable
Copy code
with Flow(
    environment=DaskKubernetesEnvironment(min_workers=1, max_workers=3),
) as flow:
    secret = EnvVarSecret('FOO', cast=str, raise_if_missing=True)
and run it using the Kubernetes agent. Now the process is bit different, the flow run is picked by the k8s agent, it spawns a job (all the same as previously) and the job executes the DaskKubernetesEnvironment that creates another dask job. The problem I have is the
variable is lost in the last step.
Kubernetes agent  --[env variables]--> Kubernetes job --[no env vars]--> dask job
. Checking the code there is indeed nothing passing env vars. How should I populate the env vars for dask jobs?

Vladimir Zoubritsky

12/16/2020, 1:17 PM
I'm not sure how it's done with the Environment, but using the new DaskExecutor feature it's possible to customize the pod like
Copy code
                    'pod_template': make_pod_spec(env={'HELLO': 'world'})