Skip to content

Commit dc4a051

Browse files
committed
Changed ingress creation to use base-template
1 parent 29a4fe8 commit dc4a051

File tree

4 files changed

+221
-187
lines changed

4 files changed

+221
-187
lines changed

src/codeflare_sdk/cluster/cluster.py

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ def create_app_wrapper(self):
131131
image_pull_secrets = self.config.image_pull_secrets
132132
dispatch_priority = self.config.dispatch_priority
133133
ingress_domain = self.config.ingress_domain
134+
ingress_options = self.config.ingress_options
134135
return generate_appwrapper(
135136
name=name,
136137
namespace=namespace,
@@ -153,6 +154,7 @@ def create_app_wrapper(self):
153154
dispatch_priority=dispatch_priority,
154155
priority_val=priority_val,
155156
ingress_domain=ingress_domain,
157+
ingress_options=ingress_options,
156158
)
157159

158160
# creates a new cluster with the provided or default spec
@@ -174,17 +176,6 @@ def up(self):
174176
plural="appwrappers",
175177
body=aw,
176178
)
177-
if self.config.ingress_options != {}: # pragma: no cover
178-
generate_custom_ingresses(
179-
self.config.ingress_options, namespace, self.config.name
180-
)
181-
else:
182-
generate_default_ingresses(
183-
self.config.name,
184-
namespace,
185-
self.config.ingress_domain,
186-
self.config.local_interactive,
187-
)
188179

189180
except Exception as e: # pragma: no cover
190181
return _kube_api_error_handling(e)
@@ -207,12 +198,6 @@ def down(self):
207198
)
208199
except Exception as e: # pragma: no cover
209200
return _kube_api_error_handling(e)
210-
_delete_generated_ingresses(
211-
self.config.ingress_options,
212-
namespace,
213-
self.config.name,
214-
self.config.local_interactive,
215-
) # pragma: no cover
216201

217202
def status(
218203
self, print_to_console: bool = True
@@ -512,31 +497,6 @@ def get_cluster(cluster_name: str, namespace: str = "default"):
512497

513498

514499
# private methods
515-
def _delete_generated_ingresses(
516-
ingress_options, namespace, clusterName, local_interactive
517-
): # pragma: no cover
518-
ingressNames = []
519-
if ingress_options != {}:
520-
for ingress_option in ingress_options["ingresses"]:
521-
ingressNames.append(ingress_option["ingressName"])
522-
else:
523-
ingressNames.append(f"ray-dashboard-ingress-{clusterName}-{namespace}")
524-
if local_interactive:
525-
ingressNames.append(f"rayclient-ingress-{clusterName}-{namespace}")
526-
527-
config_check()
528-
api_client = client.CustomObjectsApi(api_config_handler())
529-
for ingressName in ingressNames:
530-
try:
531-
api_client.delete_namespaced_custom_object(
532-
group="networking.k8s.io",
533-
version="v1",
534-
namespace=namespace,
535-
plural="ingresses",
536-
name=ingressName,
537-
)
538-
except Exception as e: # pragma: no cover
539-
print(f"Error deleting Ingress resource: {str(e)}")
540500

541501

542502
# Cant test this until get_current_namespace is fixed

src/codeflare_sdk/templates/base-template.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,51 @@ spec:
287287
optional: false
288288
- name: server-cert
289289
emptyDir: {}
290+
- replicas: 1
291+
generictemplate:
292+
apiVersion: networking.k8s.io/v1
293+
kind: Ingress
294+
metadata:
295+
name: ray-dashboard-raytest
296+
namespace: default
297+
annotations:
298+
annotations-example:annotations-example
299+
spec:
300+
rules:
301+
- http:
302+
paths:
303+
- backend:
304+
service:
305+
name: raytest-head-svc
306+
port:
307+
number: 8265
308+
pathType: Prefix
309+
path: /
310+
host: ray-dashboard-raytest.<ingress-domain>
311+
- replicas: 1
312+
generictemplate:
313+
apiVersion: networking.k8s.io/v1
314+
kind: Ingress
315+
metadata:
316+
name: rayclient-deployment-name
317+
namespace: default
318+
annotations:
319+
annotations-example:annotations-example
320+
labels:
321+
odh-ray-cluster-service: deployment-name-head-svc
322+
spec:
323+
ingressClassName: openshift-default
324+
rules:
325+
- http:
326+
paths:
327+
- backend:
328+
service:
329+
name: deployment-name-head-svc
330+
port:
331+
number: 10001
332+
path: ''
333+
pathType: ImplementationSpecific
334+
host: rayclient-raytest.<ingress-domain>
290335
- replicas: 1
291336
generictemplate:
292337
apiVersion: v1

src/codeflare_sdk/templates/ingress-template.yaml.tmpl

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)