Hello,
I'm doing a POC on prefect and trying to set up a flow that calls a python script. The script requires some environment variables (database host name, database user, database password). How do I implement these in the deployment and/or flow?
a
alex
10/26/2023, 6:26 PM
Hey @Erin! How are you planning on creating your deployment? The method for setting environment variables will differ depending on how you create your deployment.
e
Erin
10/26/2023, 6:43 PM
Hi @alex,
That is a great question. At this point I'm just walking through the tutorial documents, so I have just a simple .serve(). I'm not sure of other options yet.
a
alex
10/26/2023, 6:49 PM
Awesome!
.serve()
is a great way to schedule a Python script and make it triggerable. If you’re using
.serve()
, you can set the environment variables on the instance running your serve script. If you bake your serve script and any accompanying code into a Docker image, that can make it easy to set environment variables in a declarative and portable way.
e
Erin
10/26/2023, 6:54 PM
Thank you! If we're using Kubernetes, is the ideal option to run in a Docker image?
a
alex
10/26/2023, 6:58 PM
Yeah, that would be a great way to host your workflow in production! We have a guide that walks through building an image and an example of deploying that image to Kubernetes. I think it will help you get started, but let me know if you have any other questions!
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.