Skip to content
Quickstart

Quickstart

This runs a Prefect server, a worker, and a scheduled flow in one namespace. It takes about five minutes, most of it pulling the Prefect image.

1. Start a Prefect server

server.yaml
apiVersion: prefect.io/v1
kind: PrefectServer
metadata:
  name: prefect
spec: {}
kubectl apply -f server.yaml
kubectl get prefectserver prefect --watch

An empty spec gives an ephemeral server: its database is SQLite in an emptyDir, so it loses everything when the pod restarts. Wait for READY to become true:

NAME      VERSION   READY
prefect   3.9.4     true

The operator created a Deployment and a Service, both named prefect, and owns them:

kubectl get deployment,service -l prefect.io/server=prefect

2. Add a work pool and a worker

A work pool is a named queue of flow runs in Prefect. A worker is a process that polls one work pool and runs what it finds. The process type runs each flow as a subprocess of the worker, which keeps this example to one pod.

work-pool.yaml
apiVersion: prefect.io/v1
kind: PrefectWorkPool
metadata:
  name: process-pool
spec:
  type: process
  server:
    name: prefect
  workers: 1
kubectl apply -f work-pool.yaml
kubectl get prefectworkpool process-pool
NAME           TYPE      VERSION   READY   DESIRED WORKERS   READY WORKERS
process-pool   process   3.9.4     true    1                 1

3. Deploy a flow

A Prefect deployment tells Prefect where a flow’s code is and when to run it. This one clones a public repository and runs hello from flows/hello_world.py every minute:

deployment.yaml
apiVersion: prefect.io/v1
kind: PrefectDeployment
metadata:
  name: hello
spec:
  server:
    name: prefect
  workPool:
    name: process-pool
  deployment:
    entrypoint: flows/hello_world.py:hello
    pullSteps:
      - prefect.deployments.steps.git_clone:
          repository: https://github.com/PrefectHQ/examples.git
          branch: main
    parameters:
      name: Kubernetes
    schedules:
      - slug: every-minute
        cron: "* * * * *"
kubectl apply -f deployment.yaml
kubectl get prefectdeployment hello -o jsonpath='{.status.conditions[?(@.type=="Synced")]}{"\n"}'

Within a minute or two, the worker’s logs show the flow run:

kubectl logs deployment/process-pool -f

4. Open the Prefect UI

kubectl port-forward service/prefect 4200:4200

Open http://localhost:4200. The deployment hello is under Deployments, and its runs are under Runs.

Clean up

kubectl delete -f server.yaml -f work-pool.yaml -f deployment.yaml

The command waits while the operator deletes the deployment and the work pool from Prefect. The PrefectServer stays up until both are gone, and then Kubernetes deletes it along with its Deployment and Service. See Deleting a server.

Next steps