Hi there! Is there an environment variable that ca...
# prefect-community
b
Hi there! Is there an environment variable that can be set on Kubernetes Agents in order to populate environment variables for flow runs managed by that agent? I see in the docs that you can run:
Copy code
prefect agent <AGENT TYPE> start --env KEY=VALUE --env KEY2=VALUE2
Instead, is it possible to do this by setting an environment variable on the agent, similar to how labels are set?
Copy code
- name: PREFECT__CLOUD__AGENT__LABELS
  value: "[]"
k
Hey @Billy McMonagle, I believe the means to set your environment variables can be through the CLI as you mentioned, a Python client, a Run Config, or in the environment itself. I believe you can also set them with a YAML file for a container installation of the Agent.
b
Thank you @Kyle Moon-Wright... this is exactly the kind of thing I had in mind:
Any lowercase Prefect configuration key can be set by environment variable. In order to do so, prefix the variable with
PREFECT__
and use two underscores (
__
) to separate each part of the key.
For example, if you set
PREFECT__TASKS__DEFAULTS__MAX_RETRIES=4
, then
prefect.config.tasks.defaults.max_retries == 4
.
But it doesn't look like the flow environment variables are ever set like
prefect.config.agent.env
I probably just need to get more comfortable with helm templating and do the
--env Key=VALUE
thing.
k
hmm, this could be a feature request as I believe environment variables defined like
PREFECT__TASKS__DEFAULTS__MAX_RETRIES=4
will apply to all your flows globally, rather than be delegated to an individual Agent, whose env vars would need to be configured independently by one of the means mentioned above.
I’ll keep thinking on this though! There may be a hidden way I’m not thinking of…