Andrew Allen
08/07/2025, 5:55 PMRayTaskRunner
or DaskTaskRunner
on kubernetes.Andrew Allen
08/07/2025, 5:55 PM┌─────────────────────────────────────────────────────────────────┐
│ Kubernetes Cluster │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────┐ ┌─────────────────────────┐ │
│ │ Prefect Server │◄─────────────┤ Prefect Agent │ │
│ │ - Flow Registry │ │ - Polls for work │ │
│ │ - Orchestration │ │ - Creates K8s Jobs │ │
│ │ - State Mgmt │ │ - Monitors execution │ │
│ └─────────────────┘ └─────────────────────────┘ │
│ │ │ │
│ │ │ │
│ ▼ ▼ │
│ ┌─────────────────┐ ┌─────────────────────────┐ │
│ │ Main Flow │ │ K8s Job Controller │ │
│ │ Pod │◄─────────────┤ - Pod lifecycle mgmt │ │
│ │ - Coordinates │ │ - Resource allocation │ │
│ │ - Defines deps │ │ - Failure handling │ │
│ └─────────────────┘ └─────────────────────────┘ │
│ │ │ │
│ │ Spawns Sub-Flows │ │
│ ├───────────────┬───────────────────┼──────────────────┤
│ │ │ │ │
│ ▼ ▼ ▼ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Sub-Flow 1 │ │ Sub-Flow 2 │ │ Sub-Flow 3 │ │
│ │ Pod │ │ Pod │ │ Pod │ │
│ │ │ │ │ │ │ │
│ │ ┌─────────┐ │ │ ┌─────────┐ │ │ ┌─────────┐ │ │
│ │ │ Task 1A │ │ │ │ Task 2A │ │ │ │ Task 3A │ │ │
│ │ └─────────┘ │ │ └─────────┘ │ │ └─────────┘ │ │
│ │ ┌─────────┐ │ │ ┌─────────┐ │ │ ┌─────────┐ │ │
│ │ │ Task 1B │ │ │ │ Task 2B │ │ │ │ Task 3B │ │ │
│ │ └─────────┘ │ │ └─────────┘ │ │ └─────────┘ │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │ │ │ │
│ └───────────────┼───────────────────┘ │
│ │ │
│ ▼ │
│ Reports State Back │
└─────────────────────────────────────────────────────────────────┘
Brendan Dalpe
08/11/2025, 1:29 PMasyncio.gather
to run your subflows if you need your main flow to wait for the subflows to complete. Take a look at a simple example here: https://github.com/PrefectHQ/prefect-recipes/blob/main/flows-starter/async_subflows.pyBrendan Dalpe
08/11/2025, 1:30 PMrun_deployment
to dispatch the subflow in a separate Pod: https://docs.prefect.io/v3/how-to-guides/deployments/run-deployments#run-a-deployment-from-pythonAndrew Allen
08/11/2025, 3:54 PMasyncio.gather
method invoke a K8s job for each sub-flow
?Brendan Dalpe
08/11/2025, 3:54 PM