Hi all, I'm working on our migration from Prefect ...
# ask-community
f
Hi all, I'm working on our migration from Prefect 1 to 2, especially for the deployment. With Prefect 1, I build my Docker image, push to Artifact Registry in GCP, then I register my flow to Prefect Cloud (and adding some parameters like CronSchedule, Dask runner, etc...). Is this always a good way to deploy a flow with Prefect 2? I can't find any example with a private GCP registry for Docker image.
t
This is certainly doable in Prefect 2! Prefect projects (not to be confused with the folder concept in Prefect 1 project) allow you to specify a build step that most commonly entails building an image. Then you can set up a prefect worker in GCP. What type of GCP service? GKE, Cloud Run Jobs. etc?
f
Thank you ! I update my Prefect version to avoid Projects, looks great. With my Prefect 1 setup, I use GKE I try to make a simply and dummy deployment but I can't upload my docker image on a private registry. I specify my url (like
<http://eu.gcr.io|eu.gcr.io>
for GCP) but the log indicates an other URL
Copy code
docker.errors.APIError: 500 Server Error for <http+docker://localhost/v1.42/auth>: Internal Server Error ("Get "<https://eu.gcr.io/v2/>": unauthorized: Not Authorized.")
I create a block with
docker-registry-credentials
to store my credentials.
f
For the moment, I have my credentials parameters (via a block) like this :
Copy code
build:
    - prefect_docker.projects.steps.build_docker_image:
        requires: prefect-docker
        image_name: repo-name/image-name
        tag: dev
        dockerfile: Dockerfile
        push: True
        credentials: "{{ prefect.blocks.docker-registry-credentials.dev-registry }}"
In the build section, not in the push, because
prefect_docker
doesn't have a push method, all is done in the build. But I'm not sure : I have to use
prefect_docker
to build and then
prefect_gcp
to push? Or all is done by
prefect_docker
. Maybe I misunderstand
Oh, can
prefect_docker
upload my image only on Docker registry? So I have to pass the push parameter to False and to upload after with
prefect_gcp
?
Don't think so, because the push method of
prefect_gcp
push the content of the working directory to GCS and not a Docker image. Or I have to create a temporary folder with my Docker image inside it and then push this folder to GCS? I'm not sure, I think it exists an easier way that I've not already found
t
No you are right I believe. IIRC the build step refers to docker containers and the push step refers to pushing flow code updates.
Let me ask another engineer and get back to you.
f
Thank you @Taylor Curran, let me know when you have more infos 🙏