Hello everybody! I've been playing around with th...
# prefect-gcp
a
Hello everybody! I've been playing around with the idea of self hosting Prefect server on a VM instance using docker compose. The following posts have gotten me pretty much all the way to having a working self-host option: • https://dev.to/calvinqc/the-easiest-docker-docker-compose-setup-on-compute-engine-1op1https://medium.com/the-prefect-blog/how-to-self-host-prefect-orion-with-postgres-using-docker-compose-631c41ab8a9f I am able to just set my local
PREFECT_API_URL
env var to the external IP address of my vm instance (not the nicest solution but I can clean this up later) and then I can immediately push my blocks and deployments to the server! 👍 The problem comes from when I lauch a run of one of my test deployments that use a Cloud Run Job. I never get out of the "Pending" status in the Prefect UI. Pretty sure it is something with my networking and probably not an actual issue with Prefect, but I can't seem to make any progress. I've tried setting up Serverless VPC Connections to allow the Cloud Run Job to be able to connect to the vm that has the server running, but maybe I've set it up incorrectly 🤷. Anyone else ever managed to get a cloud run job deployment to work with a vm instance hosted prefect server?
n
hi @Aaron Gonzalez - where is your agent/worker running? can you see the flow run submission in the agent/worker logs?
a
Hey @Nate. Sorry I left out some of that context. My agent is just running in my local terminal. I can see that the job is successfully submitted.
Copy code
Starting v2.10.12 agent connected to http://<MY_VM_EXTERNAL_IP>:4200/api...

  ___ ___ ___ ___ ___ ___ _____     _   ___ ___ _  _ _____
 | _ \ _ \ __| __| __/ __|_   _|   /_\ / __| __| \| |_   _|
 |  _/   / _|| _|| _| (__  | |    / _ \ (_ | _|| .` | | |
 |_| |_|_\___|_| |___\___| |_|   /_/ \_\___|___|_|\_| |_|


Agent started! Looking for work from queue(s): default...
14:25:20.114 | INFO    | prefect.agent - Submitting flow run 'dd2398ac-e227-45b2-9c1b-6eb2b8bfacbb'
14:25:20.822 | INFO    | prefect.infrastructure.cloud-run-job - Creating Cloud Run Job prefect-5fb4ea7807f94394a3dc533029dadea5
14:25:21.645 | INFO    | prefect.infrastructure.cloud-run-job - Job is not yet ready... Current condition: waiting for condition update
14:25:27.006 | INFO    | prefect.infrastructure.cloud-run-job - Submitting Cloud Run Job 'prefect-5fb4ea7807f94394a3dc533029dadea5' for execution.
14:25:27.509 | INFO    | prefect.infrastructure.cloud-run-job - Cloud Run Job 'prefect-5fb4ea7807f94394a3dc533029dadea5': Running command 'python -m prefect.engine'
14:25:27.623 | INFO    | prefect.agent - Completed submission of flow run 'dd2398ac-e227-45b2-9c1b-6eb2b8bfacbb'
And TBH I think this isn't an actual Prefect problem. I went a little crazy and opened up the firewalls to the public internet and everything worked! I just haven't been able to track down the correct IP address range to allow ingress to the VM where there server is running.
r
I don't have anything specific to add other than saying you're on the right track with Serverless VPC connections. It's definitely a GCP issue and not a Prefect issue, but it's still annoying because it's stopping you from using Prefect the way you want to. I think GCP makes this more difficult than it needs to be. I found the equivalent setup on Azure quite a bit easier. If I can find the time later today I'll see if I can a VPC connection working from Cloud Run to a self-hosted Prefect server so I can maybe add a Cloud Run branch to https://github.com/rpeden/prefect-docker-compose with instructions.
176 Views