@Marvin what's the best way to pass environment variables to a deployment? can I specify them in the prefect.yaml?
m
Marvin
03/22/2024, 6:02 PM
To pass environment variables to a deployment, you can specify them using the
job_variables
parameter when deploying. This allows you to override default values in a work pool’s base job template, including environment variables like
image_pull_policy
and
image
. You can also specify environment variables through the work pool settings, particularly for Kubernetes work pools.
Here is an example of how to pass environment variables when deploying:
Copy code
python
if __name__ == "__main__":
get_repo_info.deploy(
name="my-deployment-never-pull",
work_pool_name="my-docker-pool",
job_variables={"image_pull_policy": "Never"}, # Override environment variables here
image="my-image:my-tag",
push=False
)
And you can also configure environment variables in a Kubernetes work pool through its settings in the Prefect UI or Prefect CLI.
For further details, visit the following links:
- Prefect Deployment Guide
- Kubernetes Deployment Guide
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.