Skip to content

Remove ingress/routes logic from SDK #495

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 2 commits into from
Apr 5, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/e2e_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ jobs:
cd codeflare-operator
echo Deploying CodeFlare operator
IMG="${REGISTRY_ADDRESS}"/codeflare-operator
sed -i 's/RayDashboardOAuthEnabled: pointer.Bool(true)/RayDashboardOAuthEnabled: pointer.Bool(false)/' main.go
make image-push -e IMG="${IMG}"
make deploy -e IMG="${IMG}" -e ENV="e2e"
kubectl wait --timeout=120s --for=condition=Available=true deployment -n openshift-operators codeflare-operator-manager
Expand Down
100 changes: 0 additions & 100 deletions src/codeflare_sdk/cluster/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,6 @@ def create_app_wrapper(self):
local_interactive = self.config.local_interactive
image_pull_secrets = self.config.image_pull_secrets
dispatch_priority = self.config.dispatch_priority
ingress_domain = self.config.ingress_domain
ingress_options = self.config.ingress_options
write_to_file = self.config.write_to_file
verify_tls = self.config.verify_tls
return generate_appwrapper(
Expand All @@ -213,8 +211,6 @@ def create_app_wrapper(self):
image_pull_secrets=image_pull_secrets,
dispatch_priority=dispatch_priority,
priority_val=priority_val,
ingress_domain=ingress_domain,
ingress_options=ingress_options,
write_to_file=write_to_file,
verify_tls=verify_tls,
)
Expand Down Expand Up @@ -493,8 +489,6 @@ def torchx_config(
def from_k8_cluster_object(
rc,
mcad=True,
ingress_domain=None,
ingress_options={},
write_to_file=False,
verify_tls=True,
):
Expand All @@ -512,11 +506,6 @@ def from_k8_cluster_object(
else []
)

if local_interactive and ingress_domain == None:
ingress_domain = rc["metadata"]["annotations"][
"sdk.codeflare.dev/ingress_domain"
]

cluster_config = ClusterConfiguration(
name=rc["metadata"]["name"],
namespace=rc["metadata"]["namespace"],
Expand Down Expand Up @@ -553,8 +542,6 @@ def from_k8_cluster_object(
]["image"],
local_interactive=local_interactive,
mcad=mcad,
ingress_domain=ingress_domain,
ingress_options=ingress_options,
write_to_file=write_to_file,
verify_tls=verify_tls,
)
Expand Down Expand Up @@ -661,62 +648,9 @@ def get_cluster(
for rc in rcs["items"]:
if rc["metadata"]["name"] == cluster_name:
mcad = _check_aw_exists(cluster_name, namespace)
ingress_host = None
ingress_options = {}
if not is_openshift_cluster():
try:
config_check()
api_instance = client.NetworkingV1Api(api_config_handler())
ingresses = api_instance.list_namespaced_ingress(namespace)
for ingress in ingresses.items:
# Search for ingress with AppWrapper name as the owner
if (
"ingress-owner" in ingress.metadata.labels
and ingress.metadata.labels["ingress-owner"] == cluster_name
):
ingress_host = ingress.spec.rules[0].host
if (
"ingress-options" in ingress.metadata.labels
and ingress.metadata.labels["ingress-options"] == "true"
):
ingress_name = ingress.metadata.name
port = (
ingress.spec.rules[0]
.http.paths[0]
.backend.service.port.number
)
annotations = ingress.metadata.annotations
path = ingress.spec.rules[0].http.paths[0].path
ingress_class_name = ingress.spec.ingress_class_name
path_type = (
ingress.spec.rules[0].http.paths[0].path_type
)

ingress_options = {
"ingresses": [
{
"ingressName": ingress_name,
"port": port,
"annotations": annotations,
"ingressClassName": ingress_class_name,
"pathType": path_type,
"path": path,
"host": ingress_host,
}
]
}
except Exception as e: # pragma: no cover
return _kube_api_error_handling(e)
# We gather the ingress domain from the host
if ingress_host is not None and ingress_options == {}:
ingress_domain = ingress_host.split(".", 1)[1]
else:
ingress_domain = None
return Cluster.from_k8_cluster_object(
rc,
mcad=mcad,
ingress_domain=ingress_domain,
ingress_options=ingress_options,
write_to_file=write_to_file,
verify_tls=verify_tls,
)
Expand All @@ -739,24 +673,6 @@ def _delete_resources(
plural="rayclusters",
name=name,
)
elif resource["kind"] == "Ingress":
name = resource["metadata"]["name"]
api_instance.delete_namespaced_custom_object(
group="networking.k8s.io",
version="v1",
namespace=namespace,
plural="ingresses",
name=name,
)
elif resource["kind"] == "Route":
name = resource["metadata"]["name"]
api_instance.delete_namespaced_custom_object(
group="route.openshift.io",
version="v1",
namespace=namespace,
plural="routes",
name=name,
)
elif resource["kind"] == "Secret":
name = resource["metadata"]["name"]
secret_instance = client.CoreV1Api(api_config_handler())
Expand All @@ -776,22 +692,6 @@ def _create_resources(yamls, namespace: str, api_instance: client.CustomObjectsA
plural="rayclusters",
body=resource,
)
elif resource["kind"] == "Ingress":
api_instance.create_namespaced_custom_object(
group="networking.k8s.io",
version="v1",
namespace=namespace,
plural="ingresses",
body=resource,
)
elif resource["kind"] == "Route":
api_instance.create_namespaced_custom_object(
group="route.openshift.io",
version="v1",
namespace=namespace,
plural="routes",
body=resource,
)
elif resource["kind"] == "Secret":
secret_instance = client.CoreV1Api(api_config_handler())
secret_instance.create_namespaced_secret(
Expand Down
2 changes: 0 additions & 2 deletions src/codeflare_sdk/cluster/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ class ClusterConfiguration:
local_interactive: bool = False
image_pull_secrets: list = field(default_factory=list)
dispatch_priority: str = None
ingress_options: dict = field(default_factory=dict)
ingress_domain: str = None
write_to_file: bool = False
verify_tls: bool = True

Expand Down
85 changes: 0 additions & 85 deletions src/codeflare_sdk/templates/base-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -338,91 +338,6 @@ spec:
- key: odh-ca-bundle.crt
path: odh-ca-bundle.crt
optional: true
- replicas: 1
generictemplate:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ray-dashboard-deployment-ingress
namespace: default
annotations:
annotations-example:annotations-example
labels:
ingress-options: "false"
ingress-owner: appwrapper-name
spec:
ingressClassName: nginx
rules:
- http:
paths:
- backend:
service:
name: raytest-head-svc
port:
number: 8265
pathType: Prefix
path: /
host: ray-dashboard-raytest.<ingress-domain>
- replicas: 1
generictemplate:
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: ray-dashboard-deployment-route
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
tls:
termination: edge
- replicas: 1
generictemplate:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: rayclient-deployment-ingress
namespace: default
annotations:
annotations-example:annotations-example
labels:
odh-ray-cluster-service: deployment-name-head-svc
spec:
ingressClassName: nginx
rules:
- http:
paths:
- backend:
service:
name: deployment-name-head-svc
port:
number: 10001
path: ''
pathType: ImplementationSpecific
host: rayclient-raytest.<ingress-domain>
- replicas: 1
generictemplate:
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: rayclient-deployment-route
namespace: default
labels:
# allows me to return name of service that Ray operator creates
odh-ray-cluster-service: deployment-name-head-svc
spec:
port:
targetPort: client
tls:
termination: passthrough
to:
kind: Service
name: deployment-name-head-svc
- replicas: 1
generictemplate:
apiVersion: v1
Expand Down
Loading