Skip to content

Commit

Permalink
Enable overwrites of default environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Dedden committed Mar 8, 2024
1 parent b668cc6 commit f49cbda
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions dask_kubernetes/operator/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,21 +153,25 @@ def build_worker_deployment_spec(
"metadata": metadata,
"spec": spec,
}
env = [
{
worker_env = {
"name": "DASK_WORKER_NAME",
"value": worker_name,
},
{
"name": "DASK_SCHEDULER_ADDRESS",
"value": f"tcp://{cluster_name}-scheduler.{namespace}.svc.cluster.local:8786",
},
]
}
scheduler_env = {
"name": "DASK_SCHEDULER_ADDRESS",
"value": f"tcp://{cluster_name}-scheduler.{namespace}.svc.cluster.local:8786",
}
for container in deployment_spec["spec"]["template"]["spec"]["containers"]:
if "env" in container:
container["env"].extend(env)
else:
container["env"] = env
if "env" not in container:
container["env"] = [worker_env, scheduler_env]
continue

container_env_names = [env_item["name"] for env_item in container["env"]]

if "DASK_WORKER_NAME" not in container_env_names:
container["env"].append(worker_env)
if "DASK_SCHEDULER_ADDRESS" not in container_env_names:
container["env"].append(scheduler_env)
return deployment_spec


Expand Down

0 comments on commit f49cbda

Please sign in to comment.