Hristo Mavrodiev
09/27/2025, 7:01 AMMarvin
09/27/2025, 7:02 AMHristo Mavrodiev
09/27/2025, 7:02 AMMarvin
09/27/2025, 7:08 AMprefect config set PREFECT_API_URL="http://<your-host-or-domain>:4200/api"
Docs: Self-hosted Server on Kubernetes (Helm)
2) Create a Kubernetes work pool (one-time)
prefect work-pool create my-k8s --type kubernetes
Concepts: Work pools and Workers
3) Start a worker that polls that pool
- Best practice: run the worker inside your cluster (via Helm). If you haven’t installed a worker yet, install the Prefect Kubernetes worker Helm chart and configure it with:
- PREFECT_API_URL pointing to your server (e.g., http//<host>4200/api)
- The work pool name you created (e.g., my-k8s)
- Reference: Deploy a worker using Helm (Kubernetes)
- For a quick test (with kubeconfig and permissions), you can also start a worker from your machine:
prefect worker start -p my-k8s
4) Create and register a deployment for your flow
Option A: Python API (works anywhere, minimal config)
from prefect import flow
from prefect.flows import Flow
@flow
def my_flow():
print("hello from k8s")
# Run this once to register the deployment with your server
deployment_id = Flow.from_source(
source="<https://github.com/<owner>/<repo>>",
entrypoint="flows/my_flow.py:my_flow",
).deploy(
name="k8s",
work_pool_name="my-k8s",
)
print("Deployment created:", deployment_id)
Option B: CLI from your project root (prefect.yaml-based)
- From your project root, you can run:
prefect deploy ./flows/my_flow.py:my_flow --name k8s
- If your project config doesn’t set a default work pool, the CLI will prompt you to choose one; select my-k8s
.
Docs: prefect.yaml and deployments
5) Trigger a run
prefect deployment run "my_flow/k8s" --watch
You should see the flow run queuing in your Server UI and picked up by the worker.
Troubleshooting checklist
- If the run stays “Scheduled”: confirm a worker is running and polling the correct pool (my-k8s
).
- If you don’t see deployments: ensure PREFECT_API_URL
is set both in your local env (for deploy) and in the worker environment (so it can talk to the server).
- Networking: verify your Server’s API is reachable at http(s)://<host-or-domain>:4200/api
(or your Ingress URL). For quick local access, you can also port-forward:
kubectl -n <namespace> port-forward svc/prefect-server 4200:4200
If you share your Server URL and whether you’ve installed a worker already, I can provide an exact Helm values snippet for the worker to point at your server and pool.Hristo Mavrodiev
09/27/2025, 7:16 AMHristo Mavrodiev
09/27/2025, 7:24 AM