Skip to content

Commit 9f629f8

Browse files
Remove ingress/routes logic from SDK (#495)
* WIP - Remove ingress/routes logic from SDK * Remove ingress_options and update tests
1 parent 403cca6 commit 9f629f8

13 files changed

+139
-688
lines changed

.github/workflows/e2e_tests.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
cd codeflare-operator
8585
echo Deploying CodeFlare operator
8686
IMG="${REGISTRY_ADDRESS}"/codeflare-operator
87+
sed -i 's/RayDashboardOAuthEnabled: pointer.Bool(true)/RayDashboardOAuthEnabled: pointer.Bool(false)/' main.go
8788
make image-push -e IMG="${IMG}"
8889
make deploy -e IMG="${IMG}" -e ENV="e2e"
8990
kubectl wait --timeout=120s --for=condition=Available=true deployment -n openshift-operators codeflare-operator-manager

src/codeflare_sdk/cluster/cluster.py

-100
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,6 @@ def create_app_wrapper(self):
187187
local_interactive = self.config.local_interactive
188188
image_pull_secrets = self.config.image_pull_secrets
189189
dispatch_priority = self.config.dispatch_priority
190-
ingress_domain = self.config.ingress_domain
191-
ingress_options = self.config.ingress_options
192190
write_to_file = self.config.write_to_file
193191
verify_tls = self.config.verify_tls
194192
return generate_appwrapper(
@@ -213,8 +211,6 @@ def create_app_wrapper(self):
213211
image_pull_secrets=image_pull_secrets,
214212
dispatch_priority=dispatch_priority,
215213
priority_val=priority_val,
216-
ingress_domain=ingress_domain,
217-
ingress_options=ingress_options,
218214
write_to_file=write_to_file,
219215
verify_tls=verify_tls,
220216
)
@@ -493,8 +489,6 @@ def torchx_config(
493489
def from_k8_cluster_object(
494490
rc,
495491
mcad=True,
496-
ingress_domain=None,
497-
ingress_options={},
498492
write_to_file=False,
499493
verify_tls=True,
500494
):
@@ -512,11 +506,6 @@ def from_k8_cluster_object(
512506
else []
513507
)
514508

515-
if local_interactive and ingress_domain == None:
516-
ingress_domain = rc["metadata"]["annotations"][
517-
"sdk.codeflare.dev/ingress_domain"
518-
]
519-
520509
cluster_config = ClusterConfiguration(
521510
name=rc["metadata"]["name"],
522511
namespace=rc["metadata"]["namespace"],
@@ -553,8 +542,6 @@ def from_k8_cluster_object(
553542
]["image"],
554543
local_interactive=local_interactive,
555544
mcad=mcad,
556-
ingress_domain=ingress_domain,
557-
ingress_options=ingress_options,
558545
write_to_file=write_to_file,
559546
verify_tls=verify_tls,
560547
)
@@ -661,62 +648,9 @@ def get_cluster(
661648
for rc in rcs["items"]:
662649
if rc["metadata"]["name"] == cluster_name:
663650
mcad = _check_aw_exists(cluster_name, namespace)
664-
ingress_host = None
665-
ingress_options = {}
666-
if not is_openshift_cluster():
667-
try:
668-
config_check()
669-
api_instance = client.NetworkingV1Api(api_config_handler())
670-
ingresses = api_instance.list_namespaced_ingress(namespace)
671-
for ingress in ingresses.items:
672-
# Search for ingress with AppWrapper name as the owner
673-
if (
674-
"ingress-owner" in ingress.metadata.labels
675-
and ingress.metadata.labels["ingress-owner"] == cluster_name
676-
):
677-
ingress_host = ingress.spec.rules[0].host
678-
if (
679-
"ingress-options" in ingress.metadata.labels
680-
and ingress.metadata.labels["ingress-options"] == "true"
681-
):
682-
ingress_name = ingress.metadata.name
683-
port = (
684-
ingress.spec.rules[0]
685-
.http.paths[0]
686-
.backend.service.port.number
687-
)
688-
annotations = ingress.metadata.annotations
689-
path = ingress.spec.rules[0].http.paths[0].path
690-
ingress_class_name = ingress.spec.ingress_class_name
691-
path_type = (
692-
ingress.spec.rules[0].http.paths[0].path_type
693-
)
694-
695-
ingress_options = {
696-
"ingresses": [
697-
{
698-
"ingressName": ingress_name,
699-
"port": port,
700-
"annotations": annotations,
701-
"ingressClassName": ingress_class_name,
702-
"pathType": path_type,
703-
"path": path,
704-
"host": ingress_host,
705-
}
706-
]
707-
}
708-
except Exception as e: # pragma: no cover
709-
return _kube_api_error_handling(e)
710-
# We gather the ingress domain from the host
711-
if ingress_host is not None and ingress_options == {}:
712-
ingress_domain = ingress_host.split(".", 1)[1]
713-
else:
714-
ingress_domain = None
715651
return Cluster.from_k8_cluster_object(
716652
rc,
717653
mcad=mcad,
718-
ingress_domain=ingress_domain,
719-
ingress_options=ingress_options,
720654
write_to_file=write_to_file,
721655
verify_tls=verify_tls,
722656
)
@@ -739,24 +673,6 @@ def _delete_resources(
739673
plural="rayclusters",
740674
name=name,
741675
)
742-
elif resource["kind"] == "Ingress":
743-
name = resource["metadata"]["name"]
744-
api_instance.delete_namespaced_custom_object(
745-
group="networking.k8s.io",
746-
version="v1",
747-
namespace=namespace,
748-
plural="ingresses",
749-
name=name,
750-
)
751-
elif resource["kind"] == "Route":
752-
name = resource["metadata"]["name"]
753-
api_instance.delete_namespaced_custom_object(
754-
group="route.openshift.io",
755-
version="v1",
756-
namespace=namespace,
757-
plural="routes",
758-
name=name,
759-
)
760676
elif resource["kind"] == "Secret":
761677
name = resource["metadata"]["name"]
762678
secret_instance = client.CoreV1Api(api_config_handler())
@@ -776,22 +692,6 @@ def _create_resources(yamls, namespace: str, api_instance: client.CustomObjectsA
776692
plural="rayclusters",
777693
body=resource,
778694
)
779-
elif resource["kind"] == "Ingress":
780-
api_instance.create_namespaced_custom_object(
781-
group="networking.k8s.io",
782-
version="v1",
783-
namespace=namespace,
784-
plural="ingresses",
785-
body=resource,
786-
)
787-
elif resource["kind"] == "Route":
788-
api_instance.create_namespaced_custom_object(
789-
group="route.openshift.io",
790-
version="v1",
791-
namespace=namespace,
792-
plural="routes",
793-
body=resource,
794-
)
795695
elif resource["kind"] == "Secret":
796696
secret_instance = client.CoreV1Api(api_config_handler())
797697
secret_instance.create_namespaced_secret(

src/codeflare_sdk/cluster/config.py

-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ class ClusterConfiguration:
5252
local_interactive: bool = False
5353
image_pull_secrets: list = field(default_factory=list)
5454
dispatch_priority: str = None
55-
ingress_options: dict = field(default_factory=dict)
56-
ingress_domain: str = None
5755
write_to_file: bool = False
5856
verify_tls: bool = True
5957

src/codeflare_sdk/templates/base-template.yaml

-85
Original file line numberDiff line numberDiff line change
@@ -338,91 +338,6 @@ spec:
338338
- key: odh-ca-bundle.crt
339339
path: odh-ca-bundle.crt
340340
optional: true
341-
- replicas: 1
342-
generictemplate:
343-
apiVersion: networking.k8s.io/v1
344-
kind: Ingress
345-
metadata:
346-
name: ray-dashboard-deployment-ingress
347-
namespace: default
348-
annotations:
349-
annotations-example:annotations-example
350-
labels:
351-
ingress-options: "false"
352-
ingress-owner: appwrapper-name
353-
spec:
354-
ingressClassName: nginx
355-
rules:
356-
- http:
357-
paths:
358-
- backend:
359-
service:
360-
name: raytest-head-svc
361-
port:
362-
number: 8265
363-
pathType: Prefix
364-
path: /
365-
host: ray-dashboard-raytest.<ingress-domain>
366-
- replicas: 1
367-
generictemplate:
368-
kind: Route
369-
apiVersion: route.openshift.io/v1
370-
metadata:
371-
name: ray-dashboard-deployment-route
372-
namespace: default
373-
labels:
374-
# allows me to return name of service that Ray operator creates
375-
odh-ray-cluster-service: deployment-name-head-svc
376-
spec:
377-
to:
378-
kind: Service
379-
name: deployment-name-head-svc
380-
port:
381-
targetPort: dashboard
382-
tls:
383-
termination: edge
384-
- replicas: 1
385-
generictemplate:
386-
apiVersion: networking.k8s.io/v1
387-
kind: Ingress
388-
metadata:
389-
name: rayclient-deployment-ingress
390-
namespace: default
391-
annotations:
392-
annotations-example:annotations-example
393-
labels:
394-
odh-ray-cluster-service: deployment-name-head-svc
395-
spec:
396-
ingressClassName: nginx
397-
rules:
398-
- http:
399-
paths:
400-
- backend:
401-
service:
402-
name: deployment-name-head-svc
403-
port:
404-
number: 10001
405-
path: ''
406-
pathType: ImplementationSpecific
407-
host: rayclient-raytest.<ingress-domain>
408-
- replicas: 1
409-
generictemplate:
410-
apiVersion: route.openshift.io/v1
411-
kind: Route
412-
metadata:
413-
name: rayclient-deployment-route
414-
namespace: default
415-
labels:
416-
# allows me to return name of service that Ray operator creates
417-
odh-ray-cluster-service: deployment-name-head-svc
418-
spec:
419-
port:
420-
targetPort: client
421-
tls:
422-
termination: passthrough
423-
to:
424-
kind: Service
425-
name: deployment-name-head-svc
426341
- replicas: 1
427342
generictemplate:
428343
apiVersion: v1

0 commit comments

Comments
 (0)