https://prefect.io logo
Title
s

Shaoyi Zhang

03/16/2022, 11:56 PM
Hi! For Kubernetes agent, is there a way to set environment variables in the Kubernetes jobs that are spun up by prefect agent pod?
I’m referring to storing secrets as environment variables, so we’d like to avoid using the env vars parameter in run config.
Technically, we can use Prefect secret, but wondering if it’s possible to specify env vars for Kuberentes jobs in Kubernetes configs(helm chart)
k

Kevin Kho

03/17/2022, 12:01 AM
On the agent when you do the
install
, you can use the
--env
flag. This will add the env var to the flows spun by the agent.
But I honestly think PrefectSecret is easier to deal with
s

Shaoyi Zhang

03/17/2022, 12:05 AM
Thank you! I’ll give it a shot
confirmed it works!
prefect agent kubernetes install --env myenv="22"
will introduce a new environment variable
PREFECT__CLOUD__AGENT__ENV_VARS
and you can add the env vars you’d like to see in Kubernetes Jobs as a JSON file.
👍 2