Thread
#prefect-community
    j

    Jared Noynaert

    1 year ago
    Is there a good way to have k8s runs inherit env vars from the agent?
    Kevin Kho

    Kevin Kho

    1 year ago
    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

    1 year ago
    @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:
    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
    Kevin Kho

    Kevin Kho

    1 year ago
    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

    1 year ago
    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