Nicholas Pini
07/10/2026, 3:07 PMMarvin
07/10/2026, 3:07 PMMarvin
07/10/2026, 3:09 PMDaskTaskRunner for Prefect tasks, and those tasks can execute on pods in your EKS cluster if the Dask workers are running on EKS.
So the architecture is:
text
Prefect flow run
-> uses DaskTaskRunner
-> submits tasks to Dask scheduler
-> Dask workers execute those tasks
-> those workers can be Kubernetes pods on EKS
Key point: Prefect itself does not turn each task into its own Kubernetes pod automatically just because you're using a task runner. The DaskTaskRunner offloads task execution to a Dask cluster. If that Dask cluster is deployed on EKS, then the task code runs on those EKS pods.
Example:
python
from prefect import flow, task
from prefect_dask import DaskTaskRunner
@task
def work(x):
return x * 2
@flow(
task_runner=DaskTaskRunner(
address="<tcp://dask-scheduler.your-namespace.svc.cluster.local:8786>"
)
)
def my_flow():
futures = [work.submit(i) for i in range(10)]
return [f.result() for f in futures]
In that setup:
- the flow run executes wherever your Prefect worker starts it
- the tasks execute on the Dask workers
- if those Dask workers are pods on EKS nodes, then yes, the tasks run on your cluster pods
You can also have Prefect create/connect to a Dask cluster dynamically via cluster_class / cluster_kwargs. DaskTaskRunner supports:
text
DaskTaskRunner(
cluster=None,
address=None,
cluster_class=None,
cluster_kwargs=None,
adapt_kwargs=None,
client_kwargs=None,
performance_report_path=None,
)
So for Kubernetes-backed Dask, the typical pattern is to use dask-kubernetes and pass a Kubernetes cluster class / config there.
A couple of important caveats:
- ThreadPoolTaskRunner and ProcessPoolTaskRunner run on the *same machine/pod as the flow run*; they do not spread tasks across EKS pods.
- If you want work on separate pods, you need an external distributed executor like Dask or Ray.
- Prefect deployments/work pools control *where the flow run starts*; the Dask cluster controls where the tasks execute.
If your goal is specifically:
“I want Prefect tasks to run on pods deployed to our EKS cluster, not Fargate”then the answer is: - Yes, by running Dask workers as pods on your EKS cluster - and configuring those pods with your usual Kubernetes node selectors / tolerations / affinity so they land on EC2-backed nodes, not Fargate Useful references: - Prefect Dask integration docs - prefect-dask usage guide - Dask on Kubernetes If you want, I can sketch the recommended EKS architecture for this in one of two ways: 1. Prefect worker on Kubernetes + existing Dask cluster on EKS 2. Prefect worker on Kubernetes + ephemeral Dask cluster created per flow run
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by