Hello, I'm doing a POC on prefect and trying to se...
# prefect-getting-started
e
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
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
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
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
Thank you! If we're using Kubernetes, is the ideal option to run in a Docker image?
a
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!
e
Thank you very much!
a
I just realized there have been some changes to the guide recently, and not all of it applies to your current use case. The parts that will be useful to you are Writing a Dockerfile, Building a Docker image, and Deploying to a remote environment.
e
Thank you so much!