Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(launch): support volume mounts and security contexts in kubernetes runner #4475

Merged
merged 21 commits into from Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/unit_tests_old/tests_launch/test_launch_kubernetes.py
Expand Up @@ -247,6 +247,7 @@ def test_launch_kube(
"node_name": "test-node-name",
"node_selectors": {"test-selector": "test-value"},
"tolerations": [{"key": "test-key", "value": "test-value"}],
"volumes": [{"name": "test-volume", "host_path": "/test/path"}],
},
},
}
Expand All @@ -272,6 +273,7 @@ def test_launch_kube(
assert job.spec.template.spec.preemption_policy == args["preemption_policy"]
assert job.spec.template.spec.node_name == args["node_name"]
assert job.spec.template.spec.tolerations == args["tolerations"]
assert job.spec.template.spec.volumes == args["volumes"]
assert (
job.spec.template.spec.node_selector["test-selector"]
== args["node_selectors"]["test-selector"]
Expand Down
3 changes: 3 additions & 0 deletions wandb/sdk/launch/runner/kubernetes.py
Expand Up @@ -169,6 +169,8 @@ def populate_pod_spec(
pod_spec["nodeSelectors"] = resource_args.get("node_selectors")
if resource_args.get("tolerations"):
pod_spec["tolerations"] = resource_args.get("tolerations")
if resource_args.get("volumes"):
KyleGoyette marked this conversation as resolved.
Show resolved Hide resolved
pod_spec["volumes"] = resource_args.get("volumes")

def populate_container_resources(
self, containers: List[Dict[str, Any]], resource_args: Dict[str, Any]
Expand Down Expand Up @@ -365,6 +367,7 @@ def run(
for cont in containers:
cont["env"] = [{"name": k, "value": v} for k, v in merged_env_vars.items()]
pod_spec["containers"] = containers

pod_template["spec"] = pod_spec
pod_template["metadata"] = pod_metadata
if secret is not None:
Expand Down