Skip to content

create dashboard route with raycluster #24

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

Merged
merged 1 commit into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/codeflare_sdk/templates/new-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,19 @@ spec:
cpu: "2"
memory: "12G"
nvidia.com/gpu: "1"
- replica: 1
generictemplate:
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: ray-dashboard-deployment-name
namespace: default
labels:
# allows me to return name of service that Ray operator creates
odh-ray-cluster-service: deployment-name-head-svc
spec:
to:
kind: Service
name: deployment-name-head-svc
port:
targetPort: dashboard
9 changes: 9 additions & 0 deletions src/codeflare_sdk/utils/generate_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ def gen_names(name):
else:
return name, name

def update_dashboard_route(route_item, cluster_name):
metadata = route_item.get("generictemplate", {}).get("metadata")
metadata["name"] = f'ray-dashboard-{cluster_name}'
metadata["labels"]["odh-ray-cluster-service"] = f'{cluster_name}-head-svc'
spec = route_item.get("generictemplate", {}).get("spec")
spec["to"]["name"] = f'{cluster_name}-head-svc'

def update_names(yaml, item, appwrapper_name, cluster_name):
metadata = yaml.get("metadata")
metadata["name"] = appwrapper_name
Expand Down Expand Up @@ -133,10 +140,12 @@ def generate_appwrapper(name, min_cpu, max_cpu, min_memory, max_memory, gpu, wor
appwrapper_name, cluster_name = gen_names(name)
resources = user_yaml.get("spec","resources")
item = resources["resources"].get("GenericItems")[0]
route_item = resources["resources"].get("GenericItems")[1]
update_names(user_yaml, item, appwrapper_name, cluster_name)
update_labels(user_yaml, instascale, instance_types)
update_custompodresources(item, min_cpu, max_cpu, min_memory, max_memory, gpu, workers)
update_nodes(item, appwrapper_name, min_cpu, max_cpu, min_memory, max_memory, gpu, workers, image, instascale, env)
update_dashboard_route(route_item, cluster_name)
outfile = appwrapper_name + ".yaml"
write_user_appwrapper(user_yaml, outfile)
return outfile
Expand Down