https://prefect.io logo
j

Jared Noynaert

07/20/2021, 3:57 PM
Is there a good way to have k8s runs inherit env vars from the agent?
k

Kevin Kho

07/20/2021, 4:11 PM
Hey @Jared Noynaert, I went through the code and it k8s RunConfig should inherit the env vars from the agent. What are you seeing?
j

Jared Noynaert

07/20/2021, 4:50 PM
@Kevin Kho we have an agent with 3 types of env vars on the agent deployment spec (config map, secret, and directly set env var). Truncated output of
kubectl describe deployment
below to clarify:
Copy code
Environment Variables from:
      prefect-agent-dev-env-secrets  Secret     Optional: false
      prefect-agent-env-vars         ConfigMap  Optional: false
    Environment:
      CONFIG_HASH:  cb7a3cd7e8afc0b4592735e5a779d0f7-0cf6bb6be4b7b1554f6b881828637963
None of those env vars are making it to the actual execution. We can exec into the agent and read the env vars correctly; when we exec into either of the two jobs spawned by each run and check the env vars we see all of the
PREFECT___
env vars populated but not the custom ones available on the agent
Everything in this chain is using Prefect 0.15.1. The agent is using the
prefecthq/prefect:0.15.1-python3.8
image
k

Kevin Kho

07/20/2021, 4:53 PM
Ok will task the team about this.
Hey @Jared Noynaert, I was wrong earlier. Only the Local agent copies env variables over. The
PREFECT__
env variable are only copied in some cases as well so this is expected behavior for k8s. You can pass env variables when you start your agent with the
--env
flag and those will be added to flow runs.
j

Jared Noynaert

07/20/2021, 7:22 PM
Got it, thanks for following up. We'll just address this by adding the same config map etc to the job template on the run config