Dask Kubernetes

2026.3.0 · active · verified Thu Apr 16

dask-kubernetes provides native integration for Dask with Kubernetes, allowing users to deploy and manage Dask clusters programmatically using the Python API (KubeCluster) or declaratively using Kubernetes Custom Resources (Dask Operator). The current version is 2026.3.0, and it follows a rapid release cadence, often monthly or quarterly, in alignment with the broader Dask ecosystem.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to create a Dask cluster on Kubernetes using `KubeCluster`, connect a Dask client, perform a simple computation, and then scale the cluster. It assumes you have `kubectl` configured and authenticated to a Kubernetes cluster.

from dask_kubernetes import KubeCluster
from dask.distributed import Client

# Ensure you have a kubectl context configured for a running Kubernetes cluster.
# KubeCluster automatically detects the current context.

# Create a Dask cluster on Kubernetes
cluster = KubeCluster(name="my-dask-cluster", n_workers=3)
print(f"Dashboard link: {cluster.dashboard_link}")

# Connect a Dask client to the cluster
client = Client(cluster)

# Perform a simple computation
def inc(x): return x + 1
def add(x, y): return x + y

futures = client.map(inc, range(10))
total = client.submit(add, *futures)
print(f"Result of computation: {total.result()}")

# Scale the cluster (optional)
cluster.scale(5)
print(f"Cluster scaled to {len(cluster.workers)} workers.")

# Close the client and cluster when done
client.close()
cluster.close()
print("Dask cluster and client closed.")

view raw JSON →