Hi guys, maybe someone can point me in the right d...
# ask-community
j
Hi guys, maybe someone can point me in the right direction: I have successfully deployed Prefect to a local Kubernetes cluster, have UI & Graphql access, but I am a little lost with the deployment of Flows to the cluster... As far as I got it I need to create a Dockerimage, and then a flow using KubernetesRun, right? But how do I deploy it then?
Copy code
flow = Flow("taskname")

flow.run_config = KubernetesRun(env={"POSTGRES_USER": "2234234",
                                    ...
                                },
                                image = "dockerimage:latest"
                                )

flow.register('projectname')
a
correct. Are you asking how to build a Docker image and push it to the registry? When it comes to Prefect deployment, registering the flow already provides all metadata needed by Prefect to schedule, run and manage the flow.
🙌 1
j
nono, just how to get it to the prefect in the cluster. because when i run python flow.py, it just says you aren't authenticated etc, but I am not using the Prefect Cloud, but the selfhosted prefect kubernetes deployment where I can not generate api keys 🤔
`prefect.exceptions.AuthorizationError: Malformed response received from Cloud - please ensure that you are authenticated. See
prefect auth login --help
.` And I am port-forwarding the ui 8080:8080, and apollo 4200:4200 from the kubernetes cluster to localhost, so the connection should be there i guess
a
one important aspect that is missing in the flow configuration you provided is Storage. Storage must be defined regardless of whether you use Cloud or Server backend. For instance, if you configure Docker storage, Prefect can automatically build the image and push it to the specified registry upon registration. If you’re looking for some examples beyond the documentation, you can check those two repositories: • https://github.com/anna-geller/packaging-prefect-flows/ • https://github.com/kvnkho/demos/tree/main/prefect
if you’re getting started with Prefect, it would be beneficial to start with Prefect Cloud rather than Server to learn all components and flow deployment patterns, since Cloud is much easier and free to use for the first 20,000 task runs each month
@Justin regarding this specific error:
Malformed response received from Cloud
you would need to switch your terminal to Server - currently you’re connected to Cloud that’s why you’re getting `AuthorizationError`:
Copy code
prefect backend server
j
hey @Anna Geller, great really useful and quick feedback 🙂 yes, I'd actually love to use prefect cloud, but I'm limited by data privacy regulations, meaning it can't touch US servers or US companies unfortunately 😉 But i will definitely check out your repos, thank you very much!
a
@Justin in case you didn’t hear about this, Prefect operates in a Hybrid execution model. Your code and data remain entirely on your infrastructure and Prefect orchestrates your flows exclusively based on metadata you send to Prefect.