Skip to content

Commit d994331

Browse files
Remove local_interactive
1 parent 65e1905 commit d994331

File tree

11 files changed

+2
-196
lines changed

11 files changed

+2
-196
lines changed

docs/cluster-configuration.md

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,11 @@ cluster = Cluster(ClusterConfiguration(
2222
image="quay.io/project-codeflare/ray:latest-py39-cu118", # Mandatory Field
2323
instascale=False, # Default False
2424
machine_types=["m5.xlarge", "g4dn.xlarge"],
25-
ingress_domain="example.com" # Default None, Mandatory for Vanilla Kubernetes Clusters - ingress_domain is ignored on OpenShift Clusters as a route is created.
26-
local_interactive=False, # Default False
2725
))
2826
```
29-
Note: On OpenShift, the `ingress_domain` is only required when `local_interactive` is enabled. - This may change soon.
3027

3128
Upon creating a cluster configuration with `mcad=True` an appwrapper will be created featuring the Ray Cluster and any Routes, Ingresses or Secrets that are needed to be created along side it.<br>
3229
From there a user can call `cluster.up()` and `cluster.down()` to create and remove the appwrapper thus creating and removing the Ray Cluster.
3330

3431
In cases where `mcad=False` a yaml file will be created with the individual Ray Cluster, Route/Ingress and Secret included.<br>
3532
The Ray Cluster and service will be created by KubeRay directly and the other components will be individually created.
36-
37-
## Ray Cluster Configuration in a Vanilla Kubernetes environment (Non-OpenShift)
38-
To create a Ray Cluster using the CodeFlare SDK in a Vanilla Kubernetes environment an `ingress_domain` must be passed in the Cluster Configuration.
39-
This is used for the creation of the Ray Dashboard and Client ingresses.
40-
41-
`ingress_options` can be passed to create a custom Ray Dashboard ingress, `ingress_domain` is still a required variable for the Client route/ingress.
42-
An example of `ingress_options` would look like this.
43-
44-
```
45-
ingress_options = {
46-
"ingresses": [
47-
{
48-
"ingressName": "<ingress_name>",
49-
"port": <port_number>,
50-
"pathType": "<path_type>",
51-
"path": "<path>",
52-
"host":"<host>",
53-
"annotations": {
54-
"foo": "bar",
55-
"foo": "bar",
56-
}
57-
}
58-
]
59-
}
60-
```

src/codeflare_sdk/cluster/cluster.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def create_app_wrapper(self):
179179
mcad = self.config.mcad
180180
instance_types = self.config.machine_types
181181
env = self.config.envs
182-
local_interactive = self.config.local_interactive
183182
image_pull_secrets = self.config.image_pull_secrets
184183
dispatch_priority = self.config.dispatch_priority
185184
write_to_file = self.config.write_to_file
@@ -203,7 +202,6 @@ def create_app_wrapper(self):
203202
mcad=mcad,
204203
instance_types=instance_types,
205204
env=env,
206-
local_interactive=local_interactive,
207205
image_pull_secrets=image_pull_secrets,
208206
dispatch_priority=dispatch_priority,
209207
priority_val=priority_val,
@@ -479,13 +477,6 @@ def from_k8_cluster_object(
479477
verify_tls=True,
480478
):
481479
config_check()
482-
if (
483-
rc["metadata"]["annotations"]["sdk.codeflare.dev/local_interactive"]
484-
== "True"
485-
):
486-
local_interactive = True
487-
else:
488-
local_interactive = False
489480
machine_types = (
490481
rc["metadata"]["labels"]["orderedinstance"].split("_")
491482
if "orderedinstance" in rc["metadata"]["labels"]
@@ -526,19 +517,15 @@ def from_k8_cluster_object(
526517
image=rc["spec"]["workerGroupSpecs"][0]["template"]["spec"]["containers"][
527518
0
528519
]["image"],
529-
local_interactive=local_interactive,
530520
mcad=mcad,
531521
write_to_file=write_to_file,
532522
verify_tls=verify_tls,
533523
)
534524
return Cluster(cluster_config)
535525

536526
def local_client_url(self):
537-
if self.config.local_interactive == True:
538-
ingress_domain = _get_ingress_domain(self)
539-
return f"ray://{ingress_domain}"
540-
else:
541-
return "None"
527+
ingress_domain = _get_ingress_domain(self)
528+
return f"ray://{ingress_domain}"
542529

543530
def _component_resources_up(
544531
self, namespace: str, api_instance: client.CustomObjectsApi

src/codeflare_sdk/cluster/config.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ class ClusterConfiguration:
4949
mcad: bool = False
5050
envs: dict = field(default_factory=dict)
5151
image: str = ""
52-
local_interactive: bool = False
5352
image_pull_secrets: list = field(default_factory=list)
5453
dispatch_priority: str = None
5554
write_to_file: bool = False

src/codeflare_sdk/templates/base-template.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ spec:
4040
apiVersion: ray.io/v1
4141
kind: RayCluster
4242
metadata:
43-
annotations:
44-
sdk.codeflare.dev/local_interactive: "False"
4543
labels:
4644
workload.codeflare.dev/appwrapper: "aw-kuberay"
4745
controller-tools.k8s.io: "1.0"

src/codeflare_sdk/utils/generate_yaml.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -277,14 +277,6 @@ def update_ca_secret(ca_secret_item, cluster_name, namespace):
277277
data["ca.key"], data["ca.crt"] = generate_cert.generate_ca_cert(365)
278278

279279

280-
def enable_local_interactive(resources): # pragma: no cover
281-
item = resources["resources"].get("GenericItems")[0]
282-
283-
item["generictemplate"]["metadata"]["annotations"][
284-
"sdk.codeflare.dev/local_interactive"
285-
] = "True"
286-
287-
288280
def del_from_list_by_name(l: list, target: typing.List[str]) -> list:
289281
return [x for x in l if x["name"] not in target]
290282

@@ -454,7 +446,6 @@ def generate_appwrapper(
454446
mcad: bool,
455447
instance_types: list,
456448
env,
457-
local_interactive: bool,
458449
image_pull_secrets: list,
459450
dispatch_priority: str,
460451
priority_val: int,
@@ -505,9 +496,6 @@ def generate_appwrapper(
505496
head_gpus,
506497
)
507498

508-
if local_interactive:
509-
enable_local_interactive(resources)
510-
511499
ca_secret_item = resources["resources"].get("GenericItems")[1]
512500
update_ca_secret(ca_secret_item, cluster_name, namespace)
513501

tests/test-case-bad.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ spec:
3232
apiVersion: ray.io/v1
3333
kind: RayCluster
3434
metadata:
35-
annotations:
36-
sdk.codeflare.dev/local_interactive: 'False'
3735
labels:
3836
workload.codeflare.dev/appwrapper: unit-test-cluster
3937
controller-tools.k8s.io: '1.0'

tests/test-case-no-mcad.yamls

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
apiVersion: ray.io/v1
33
kind: RayCluster
44
metadata:
5-
annotations:
6-
sdk.codeflare.dev/local_interactive: 'False'
75
labels:
86
controller-tools.k8s.io: '1.0'
97
kueue.x-k8s.io/queue-name: local-queue-default

tests/test-case-prio.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ spec:
3232
apiVersion: ray.io/v1
3333
kind: RayCluster
3434
metadata:
35-
annotations:
36-
sdk.codeflare.dev/local_interactive: 'False'
3735
labels:
3836
controller-tools.k8s.io: '1.0'
3937
workload.codeflare.dev/appwrapper: prio-test-cluster

tests/test-case.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ spec:
3131
apiVersion: ray.io/v1
3232
kind: RayCluster
3333
metadata:
34-
annotations:
35-
sdk.codeflare.dev/local_interactive: 'False'
3634
labels:
3735
controller-tools.k8s.io: '1.0'
3836
workload.codeflare.dev/appwrapper: unit-test-cluster

tests/test-default-appwrapper.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ spec:
2929
apiVersion: ray.io/v1
3030
kind: RayCluster
3131
metadata:
32-
annotations:
33-
sdk.codeflare.dev/local_interactive: 'False'
3432
labels:
3533
controller-tools.k8s.io: '1.0'
3634
workload.codeflare.dev/appwrapper: unit-test-default-cluster

tests/unit_test.py

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
gen_names,
7575
is_openshift_cluster,
7676
read_template,
77-
enable_local_interactive,
7877
write_components,
7978
)
8079

@@ -258,7 +257,6 @@ def test_config_creation():
258257
assert config.image_pull_secrets == ["unit-test-pull-secret"]
259258
assert config.dispatch_priority == None
260259
assert config.mcad == True
261-
assert config.local_interactive == False
262260

263261

264262
def ca_secret_support(path, mcad: bool):
@@ -746,7 +744,6 @@ def test_local_client_url(mocker):
746744
cluster_config = ClusterConfiguration(
747745
name="unit-test-cluster-localinter",
748746
namespace="ns",
749-
local_interactive=True,
750747
write_to_file=True,
751748
)
752749
cluster = Cluster(cluster_config)
@@ -1062,9 +1059,6 @@ def get_ray_obj(group, version, namespace, plural, cls=None):
10621059
"metadata": {
10631060
"creationTimestamp": "2024-03-05T09:55:37Z",
10641061
"generation": 1,
1065-
"annotations": {
1066-
"sdk.codeflare.dev/local_interactive": "True",
1067-
},
10681062
"labels": {
10691063
"appwrapper.mcad.ibm.com": "quicktest",
10701064
"controller-tools.k8s.io": "1.0",
@@ -1874,9 +1868,6 @@ def get_aw_obj(group, version, namespace, plural):
18741868
"apiVersion": "ray.io/v1",
18751869
"kind": "RayCluster",
18761870
"metadata": {
1877-
"annotations": {
1878-
"sdk.codeflare.dev/local_interactive": "False"
1879-
},
18801871
"labels": {
18811872
"workload.codeflare.dev/appwrapper": "quicktest1",
18821873
"controller-tools.k8s.io": "1.0",
@@ -2204,9 +2195,6 @@ def get_aw_obj(group, version, namespace, plural):
22042195
"apiVersion": "ray.io/v1",
22052196
"kind": "RayCluster",
22062197
"metadata": {
2207-
"annotations": {
2208-
"sdk.codeflare.dev/local_interactive": "False"
2209-
},
22102198
"labels": {
22112199
"workload.codeflare.dev/appwrapper": "quicktest2",
22122200
"controller-tools.k8s.io": "1.0",
@@ -2518,7 +2506,6 @@ def custom_side_effect(group, version, namespace, plural, **kwargs):
25182506
assert cluster_config.min_cpus == 1 and cluster_config.max_cpus == 1
25192507
assert cluster_config.min_memory == 2 and cluster_config.max_memory == 2
25202508
assert cluster_config.num_gpus == 0
2521-
assert cluster_config.local_interactive == True
25222509
assert (
25232510
cluster_config.image
25242511
== "ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103"
@@ -2552,7 +2539,6 @@ def test_get_cluster(mocker):
25522539
assert cluster_config.min_memory == 2 and cluster_config.max_memory == 2
25532540
assert cluster_config.num_gpus == 0
25542541
assert cluster_config.instascale
2555-
assert cluster_config.local_interactive
25562542
assert (
25572543
cluster_config.image
25582544
== "ghcr.io/foundation-model-stack/base:ray2.1.0-py38-gpu-pytorch1.12.0cu116-20221213-193103"
@@ -3082,120 +3068,6 @@ def test_export_env():
30823068
)
30833069

30843070

3085-
# def test_enable_local_interactive(mocker):
3086-
# template = f"{parent}/src/codeflare_sdk/templates/base-template.yaml"
3087-
# user_yaml = read_template(template)
3088-
# aw_spec = user_yaml.get("spec", None)
3089-
# cluster_name = "test-enable-local"
3090-
# namespace = "default"
3091-
# ingress_domain = "mytest.domain"
3092-
# mocker.patch("kubernetes.client.ApisApi.get_api_versions")
3093-
# mocker.patch(
3094-
# "codeflare_sdk.utils.generate_yaml.is_openshift_cluster", return_value=False
3095-
# )
3096-
# volume_mounts = [
3097-
# {"name": "ca-vol", "mountPath": "/home/ray/workspace/ca", "readOnly": True},
3098-
# {
3099-
# "name": "server-cert",
3100-
# "mountPath": "/home/ray/workspace/tls",
3101-
# "readOnly": False,
3102-
# },
3103-
# ]
3104-
# volumes = [
3105-
# {
3106-
# "name": "ca-vol",
3107-
# "secret": {"secretName": "ca-secret-test-enable-local"},
3108-
# "optional": False,
3109-
# },
3110-
# {"name": "server-cert", "emptyDir": {}},
3111-
# {
3112-
# "name": "odh-trusted-ca-cert",
3113-
# "configMap": {
3114-
# "name": "odh-trusted-ca-bundle",
3115-
# "items": [
3116-
# {"key": "ca-bundle.crt", "path": "odh-trusted-ca-bundle.crt"}
3117-
# ],
3118-
# "optional": True,
3119-
# },
3120-
# },
3121-
# {
3122-
# "name": "odh-ca-cert",
3123-
# "configMap": {
3124-
# "name": "odh-trusted-ca-bundle",
3125-
# "items": [{"key": "odh-ca-bundle.crt", "path": "odh-ca-bundle.crt"}],
3126-
# "optional": True,
3127-
# },
3128-
# },
3129-
# ]
3130-
# tls_env = [
3131-
# {"name": "RAY_USE_TLS", "value": "1"},
3132-
# {"name": "RAY_TLS_SERVER_CERT", "value": "/home/ray/workspace/tls/server.crt"},
3133-
# {"name": "RAY_TLS_SERVER_KEY", "value": "/home/ray/workspace/tls/server.key"},
3134-
# {"name": "RAY_TLS_CA_CERT", "value": "/home/ray/workspace/tls/ca.crt"},
3135-
# ]
3136-
# assert aw_spec != None
3137-
# enable_local_interactive(aw_spec, cluster_name, namespace, ingress_domain)
3138-
# head_group_spec = aw_spec["resources"]["GenericItems"][0]["generictemplate"][
3139-
# "spec"
3140-
# ]["headGroupSpec"]
3141-
# worker_group_spec = aw_spec["resources"]["GenericItems"][0]["generictemplate"][
3142-
# "spec"
3143-
# ]["workerGroupSpecs"]
3144-
# ca_secret = aw_spec["resources"]["GenericItems"][1]["generictemplate"]
3145-
# # At a minimal, make sure the following items are presented in the appwrapper spec.resources.
3146-
# # 1. headgroup has the initContainers command to generated TLS cert from the mounted CA cert.
3147-
# # Note: In this particular command, the DNS.5 in [alt_name] must match the exposed local_client_url: rayclient-{cluster_name}.{namespace}.{ingress_domain}
3148-
# assert (
3149-
# head_group_spec["template"]["spec"]["initContainers"][0]["command"][2]
3150-
# == f"cd /home/ray/workspace/tls && openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr -subj '/CN=ray-head' && printf \"authorityKeyIdentifier=keyid,issuer\\nbasicConstraints=CA:FALSE\\nsubjectAltName = @alt_names\\n[alt_names]\\nDNS.1 = 127.0.0.1\\nDNS.2 = localhost\\nDNS.3 = ${{FQ_RAY_IP}}\\nDNS.4 = $(awk 'END{{print $1}}' /etc/hosts)\\nDNS.5 = rayclient-{cluster_name}-$(cat /var/run/secrets/kubernetes.io/serviceaccount/namespace).{ingress_domain}\">./domain.ext && cp /home/ray/workspace/ca/* . && openssl x509 -req -CA ca.crt -CAkey ca.key -in server.csr -out server.crt -days 365 -CAcreateserial -extfile domain.ext"
3151-
# )
3152-
# assert (
3153-
# head_group_spec["template"]["spec"]["initContainers"][0]["volumeMounts"]
3154-
# == volume_mounts
3155-
# )
3156-
# assert head_group_spec["template"]["spec"]["volumes"] == volumes
3157-
3158-
# # 2. workerGroupSpec has the initContainers command to generated TLS cert from the mounted CA cert.
3159-
# assert (
3160-
# worker_group_spec[0]["template"]["spec"]["initContainers"][0]["command"][2]
3161-
# == "cd /home/ray/workspace/tls && openssl req -nodes -newkey rsa:2048 -keyout server.key -out server.csr -subj '/CN=ray-head' && printf \"authorityKeyIdentifier=keyid,issuer\\nbasicConstraints=CA:FALSE\\nsubjectAltName = @alt_names\\n[alt_names]\\nDNS.1 = 127.0.0.1\\nDNS.2 = localhost\\nDNS.3 = ${FQ_RAY_IP}\\nDNS.4 = $(awk 'END{print $1}' /etc/hosts)\">./domain.ext && cp /home/ray/workspace/ca/* . && openssl x509 -req -CA ca.crt -CAkey ca.key -in server.csr -out server.crt -days 365 -CAcreateserial -extfile domain.ext"
3162-
# )
3163-
# assert (
3164-
# worker_group_spec[0]["template"]["spec"]["initContainers"][0]["volumeMounts"]
3165-
# == volume_mounts
3166-
# )
3167-
# assert worker_group_spec[0]["template"]["spec"]["volumes"] == volumes
3168-
3169-
# # 3. Required Envs to enable TLS encryption between head and workers
3170-
# for i in range(len(tls_env)):
3171-
# assert (
3172-
# head_group_spec["template"]["spec"]["containers"][0]["env"][i + 1]["name"]
3173-
# == tls_env[i]["name"]
3174-
# )
3175-
# assert (
3176-
# head_group_spec["template"]["spec"]["containers"][0]["env"][i + 1]["value"]
3177-
# == tls_env[i]["value"]
3178-
# )
3179-
# assert (
3180-
# worker_group_spec[0]["template"]["spec"]["containers"][0]["env"][i + 1][
3181-
# "name"
3182-
# ]
3183-
# == tls_env[i]["name"]
3184-
# )
3185-
# assert (
3186-
# worker_group_spec[0]["template"]["spec"]["containers"][0]["env"][i + 1][
3187-
# "value"
3188-
# ]
3189-
# == tls_env[i]["value"]
3190-
# )
3191-
3192-
# # 4. Secret with ca.crt and ca.key
3193-
# assert ca_secret["kind"] == "Secret"
3194-
# assert ca_secret["data"]["ca.crt"] != None
3195-
# assert ca_secret["data"]["ca.key"] != None
3196-
# assert ca_secret["metadata"]["name"] == f"ca-secret-{cluster_name}"
3197-
# assert ca_secret["metadata"]["namespace"] == namespace
3198-
31993071
"""
32003072
Ray Jobs tests
32013073
"""

0 commit comments

Comments
 (0)