https://prefect.io logo
Title
r

Raed Shabbir

09/14/2021, 7:15 PM
Hello, I can’t seem to find the local development guide in the docs anymore, how do I start prefect server & agent locally for the first time?
k

Kevin Kho

09/14/2021, 7:17 PM
Hey @Raed Shabbir,
prefect server start
and
prefect agent local start
In 0.15.5 if you are conencting from different machines to server, you need the
--expose
flag
r

Raed Shabbir

09/14/2021, 7:19 PM
Hey Kevin, prefect server starts the UI correctly, but how can I connect to my K8S deployment with external postgresql as in earlier versions?
Also
prefect agent local start
fails with
RuntimeError: Error while contacting API at <https://api.prefect.io>
But why would the local agent have to connect to prefect-cloud? (note we are not using prefect-cloud and initially deployed via this guide
<https://www.youtube.com/watch?v=EwsMecjSYEU>
k

Kevin Kho

09/14/2021, 7:22 PM
I think you edit this to point to another postgres db. The agent contacts Prefect Cloud by default. To point it to server, you need to do
prefect backend server
r

Raed Shabbir

09/14/2021, 7:29 PM
I see, so the correct order of operations for purely local development would be 1. prefect backend server 2. prefect server start 3. prefect local agent start ?
k

Kevin Kho

09/14/2021, 7:30 PM
Yep
r

Raed Shabbir

09/14/2021, 7:48 PM
Great and what would be the recommend way to switch from local agent to our K8s deployed server?
Would it be just adding the following lines into the flow file?
# comment out 
# flow.executor = LocalExecutor()
#! For using kube 
flow.executor = DaskExecutor()

# flow.run_config = KubernetesRun(
#     image=<path to docker image>
#     env={
#         "PREFECT__CONTEXT__SECRETS__BITBUCKET_CLOUD_USERNAME": os.environ[
#             "BITBUCKET_CLOUD_USERNAME"
#         ],
#         "PREFECT__CONTEXT__SECRETS__BITBUCKET_CLOUD_APP_PASSWORD": os.environ[
#             "BITBUCKET_ACCESS_TOKEN"
#         ],
#         "PREFECT__LOGGING__LEVEL": "DEBUG",
#     },
#     image_pull_policy="Always",
# )
k

Kevin Kho

09/14/2021, 8:43 PM
The agent will connect to the Server after doing
prefect backend server
. Flows that are registered will also be registered on the server
1