i’m upgrading to prefect2 and trying to figure out...
# ask-community
s
i’m upgrading to prefect2 and trying to figure out how to make the prefect deployment work with a serverless push work pool. my infrastructure is deployed to google cloud with cloud build. does the `build` step in the prefect.yaml do the same thing? i’m wondering if i can just use that to build the docker image instead.
n
hi @Sam McAlilly, yep you can use the build step to build a docker image, that’s sort of the canonical use for it. when you ask if it “does the same thing” as the build step, what are you asking about?
s
i’m a bit confused by the build in prefect.yaml and my existing cloud build setup, which also builds the docker image. it seems like that’s redundant to do in both places. in which case, it seems unnecessary to use cloud build for doing anything?
it’s also confusing to have to
pull
in prefect.yaml when the cloud run resource is already provisioned. can
pull
provision that gcp resource instead of doing it with cloud build? edit: push, not pull edit2: had it right the first time
n
yeah if you have an existing image pipeline / other ci that does that for you, you might not need a build step. if you need very specific control over how exactly that build occurs, you might want to use your own external build system instead of a build step on your deployment, but for simple “my flow runs on docker with a couple deps” use cases, it’s nice. the pull step is usually a place to specify where your code should be fetched, eg via a git_clone step or doing other arbitrary setup with run_shell_script i don’t know the specifics of what you mean on your gcp resource question, but it’s important to note that build steps run just before deployment creation time, whereas pull steps after, just before deployment flow run execution time
s
@Nate re: gcp resources, i’m just struggling to understand how to use the prefect.yaml-controlled deployment to connect my prefect work pool with my existing google cloud run job. my cloud build set up deploys that to cloud run so the pull step seems unnecessary, but the docs say it’s required. our ci/cd with cloud build creates the cloud run job. does prefect also deploy that code to the gcp cloud run job? i’m ok with using prefect’s deploy system to deploy to cloud run if that’s the case, it’s just not clear to me
n
ok i think the confusion here is around the cloud run job if you want to use a push work pool, you dont need to worry about creating the job yourself (or even running a worker at all - we do that for you as needed) at deployment execution time, a cloud run job will be created in your infra that runs the flow. if you want to do infra allocation yourself, you probably shouldn't use a prefect deployment, since that's one of the core value props of prefect deployments --- the reason why a pull step is generally required with prefect deployments is that the worker always needs to know where the flow is, if its in github, it should pull it down, if its on the image already, set the directory etc
s
ahhhhh okay, that makes sense and helps clarify my confusion. thanks @Nate !
if you want to do infra allocation yourself, you probably shouldn’t use a prefect deployment, since that’s one of the core value props of prefect deployments
i think we’re ok with using prefect deployments, but if not, would we still be able to use the serverless push work pool pattern, or is that only available if you use a prefect deployment?
n
a work pool is a concept specific to prefect deployments, specifically, it is the base infra configuration for whatever class of infra (Docker, k8s, process etc) that a worker may try to submit a flow run onto, work pool config + whatever
job_variables
you put on a deployment in
prefect.yaml
will fully define your deployment flow run's infra
s
that’s helpful information. i think it’s all making sense now. that’s neat that prefect deployments can handle the gcp deployment, was actually wondering about the privileges of service account that’s connected to the credentials (i didn’t setup any of that, i might’ve pieced it together sooner if i had). i will think it’s very cool once i get it to work lol