How to set service account for workers

I need to set a specific service account on my workers. How is that done?

This is how I start my cluster and it works fine. I need the service account to add rights for access to aws s3. My current workaround is to use the default service account with aws s3 access and that works but I would rather be able to specify it directly on the dask cluster creation.

 cluster = KubeCluster(
    name=name,
    namespace=namespace,
    image=image,
    port_forward_cluster_ip=port_forward_cluster_ip,
    resources={"requests": {"memory": "2Gi"}, "limits": {"memory": "64Gi"}},
    scheduler_forward_port=scheduler_forward_port,
    worker_command=["dask", "worker"],
    env=env_dict,
    idle_timeout=60 * 30,
)

Thanks for your time;

Christopher

Hi @chrisspalm, welcome to Dask community!

According to dask-kubernetes documentation, you can set a specific service account on your Dask cluster component in the Helm chart configuration: Installing — Dask Kubernetes 2024.5.1.dev4+g6d3d9b2 documentation.

Would this solve your issue?

cc @jacobtomlinson

Thanks for the welcome and for your quick reply. I believe that is the service account for the operator. I want a specific service account for my workers.

You will need to follow the customizing your cluster docs to generate the cluster spec before creating it so that you can make modifications like setting a service account.

from dask_kubernetes.operator import KubeCluster, make_cluster_spec

spec = make_cluster_spec(name=name, ...)  # takes the same kwargs as KubeCluster
spec["spec"]["worker"]["spec"]["serviceAccountName"] = "foo"

cluster = KubeCluster(custom_cluster_spec=spec)

Thanks, I’ll try that!