Skip to content

Commit 0dece2a

Browse files
kryanbeanelaurafitzgerald
authored andcommitted
RHOAIENG-33283: Change ConfigMaps to Secrets and exclude .ipynb files in zipping
1 parent 8406b06 commit 0dece2a

File tree

8 files changed

+407
-215
lines changed

8 files changed

+407
-215
lines changed

.github/workflows/rayjob_e2e_tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ jobs:
115115
kubectl create clusterrolebinding sdk-user-service-reader --clusterrole=service-reader --user=sdk-user
116116
kubectl create clusterrole port-forward-pods --verb=create --resource=pods/portforward
117117
kubectl create clusterrolebinding sdk-user-port-forward-pods-binding --clusterrole=port-forward-pods --user=sdk-user
118-
kubectl create clusterrole configmap-manager --verb=get,list,create,delete,update,patch --resource=configmaps
119-
kubectl create clusterrolebinding sdk-user-configmap-manager --clusterrole=configmap-manager --user=sdk-user
118+
kubectl create clusterrole secret-manager --verb=get,list,create,delete,update,patch --resource=secrets
119+
kubectl create clusterrolebinding sdk-user-secret-manager --clusterrole=secret-manager --user=sdk-user
120120
kubectl create clusterrole workload-reader --verb=get,list,watch --resource=workloads
121121
kubectl create clusterrolebinding sdk-user-workload-reader --clusterrole=workload-reader --user=sdk-user
122122
kubectl config use-context sdk-user

src/codeflare_sdk/ray/rayjobs/config.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
from kubernetes.client import (
2525
V1ConfigMapVolumeSource,
2626
V1KeyToPath,
27+
V1LocalObjectReference,
28+
V1SecretVolumeSource,
2729
V1Toleration,
2830
V1Volume,
2931
V1VolumeMount,
@@ -415,8 +417,6 @@ def _build_pod_spec(self, container: V1Container, is_head: bool) -> V1PodSpec:
415417

416418
# Add image pull secrets if specified
417419
if hasattr(self, "image_pull_secrets") and self.image_pull_secrets:
418-
from kubernetes.client import V1LocalObjectReference
419-
420420
pod_spec.image_pull_secrets = [
421421
V1LocalObjectReference(name=secret)
422422
for secret in self.image_pull_secrets
@@ -448,12 +448,12 @@ def _build_env_vars(self) -> list:
448448
"""Build environment variables list."""
449449
return [V1EnvVar(name=key, value=value) for key, value in self.envs.items()]
450450

451-
def add_file_volumes(self, configmap_name: str, mount_path: str = MOUNT_PATH):
451+
def add_file_volumes(self, secret_name: str, mount_path: str = MOUNT_PATH):
452452
"""
453453
Add file volume and mount references to cluster configuration.
454454
455455
Args:
456-
configmap_name: Name of the ConfigMap containing files
456+
secret_name: Name of the Secret containing files
457457
mount_path: Where to mount files in containers (default: /home/ray/scripts)
458458
"""
459459
# Check if file volume already exists
@@ -478,7 +478,7 @@ def add_file_volumes(self, configmap_name: str, mount_path: str = MOUNT_PATH):
478478

479479
# Add file volume to cluster configuration
480480
file_volume = V1Volume(
481-
name=volume_name, config_map=V1ConfigMapVolumeSource(name=configmap_name)
481+
name=volume_name, secret=V1SecretVolumeSource(secret_name=secret_name)
482482
)
483483
self.volumes.append(file_volume)
484484

@@ -487,36 +487,37 @@ def add_file_volumes(self, configmap_name: str, mount_path: str = MOUNT_PATH):
487487
self.volume_mounts.append(file_mount)
488488

489489
logger.info(
490-
f"Added file volume '{configmap_name}' to cluster config: mount_path={mount_path}"
490+
f"Added file volume '{secret_name}' to cluster config: mount_path={mount_path}"
491491
)
492492

493-
def validate_configmap_size(self, files: Dict[str, str]) -> None:
493+
def validate_secret_size(self, files: Dict[str, str]) -> None:
494494
total_size = sum(len(content.encode("utf-8")) for content in files.values())
495495
if total_size > 1024 * 1024: # 1MB
496496
raise ValueError(
497-
f"ConfigMap size exceeds 1MB limit. Total size: {total_size} bytes"
497+
f"Secret size exceeds 1MB limit. Total size: {total_size} bytes"
498498
)
499499

500-
def build_file_configmap_spec(
500+
def build_file_secret_spec(
501501
self, job_name: str, namespace: str, files: Dict[str, str]
502502
) -> Dict[str, Any]:
503503
"""
504-
Build ConfigMap specification for files
504+
Build Secret specification for files
505505
506506
Args:
507-
job_name: Name of the RayJob (used for ConfigMap naming)
507+
job_name: Name of the RayJob (used for Secret naming)
508508
namespace: Kubernetes namespace
509509
files: Dictionary of file_name -> file_content
510510
511511
Returns:
512-
Dict: ConfigMap specification ready for Kubernetes API
512+
Dict: Secret specification ready for Kubernetes API
513513
"""
514-
configmap_name = f"{job_name}-files"
514+
secret_name = f"{job_name}-files"
515515
return {
516516
"apiVersion": "v1",
517-
"kind": "ConfigMap",
517+
"kind": "Secret",
518+
"type": "Opaque",
518519
"metadata": {
519-
"name": configmap_name,
520+
"name": secret_name,
520521
"namespace": namespace,
521522
"labels": {
522523
"ray.io/job-name": job_name,
@@ -528,19 +529,19 @@ def build_file_configmap_spec(
528529
}
529530

530531
def build_file_volume_specs(
531-
self, configmap_name: str, mount_path: str = MOUNT_PATH
532+
self, secret_name: str, mount_path: str = MOUNT_PATH
532533
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
533534
"""
534535
Build volume and mount specifications for files
535536
536537
Args:
537-
configmap_name: Name of the ConfigMap containing files
538+
secret_name: Name of the Secret containing files
538539
mount_path: Where to mount files in containers
539540
540541
Returns:
541542
Tuple of (volume_spec, mount_spec) as dictionaries
542543
"""
543-
volume_spec = {"name": "ray-job-files", "configMap": {"name": configmap_name}}
544+
volume_spec = {"name": "ray-job-files", "secret": {"secretName": secret_name}}
544545

545546
mount_spec = {"name": "ray-job-files", "mountPath": mount_path}
546547

src/codeflare_sdk/ray/rayjobs/rayjob.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from python_client.kuberay_cluster_api import RayClusterApi
3232
from codeflare_sdk.ray.rayjobs.config import ManagedClusterConfig
3333
from codeflare_sdk.ray.rayjobs.runtime_env import (
34-
create_file_configmap,
34+
create_file_secret,
3535
extract_all_local_files,
3636
process_runtime_env,
3737
)
@@ -169,10 +169,10 @@ def submit(self) -> str:
169169
# Extract files from entrypoint and runtime_env working_dir
170170
files = extract_all_local_files(self)
171171

172-
# Create ConfigMap for files (will be mounted to submitter pod)
173-
configmap_name = None
172+
# Create Secret for files (will be mounted to submitter pod)
173+
secret_name = None
174174
if files:
175-
configmap_name = f"{self.name}-files"
175+
secret_name = f"{self.name}-files"
176176

177177
rayjob_cr = self._build_rayjob_cr()
178178

@@ -182,9 +182,9 @@ def submit(self) -> str:
182182
if result:
183183
logger.info(f"Successfully submitted RayJob {self.name}")
184184

185-
# Create ConfigMap with owner reference after RayJob exists
185+
# Create Secret with owner reference after RayJob exists
186186
if files:
187-
create_file_configmap(self, files, result)
187+
create_file_secret(self, files, result)
188188

189189
return self.name
190190
else:
@@ -285,10 +285,10 @@ def _build_rayjob_cr(self) -> Dict[str, Any]:
285285

286286
# Add submitterPodTemplate if we have files to mount
287287
if files:
288-
configmap_name = f"{self.name}-files"
288+
secret_name = f"{self.name}-files"
289289
rayjob_cr["spec"][
290290
"submitterPodTemplate"
291-
] = self._build_submitter_pod_template(files, configmap_name)
291+
] = self._build_submitter_pod_template(files, secret_name)
292292

293293
# Configure cluster: either use existing or create new
294294
if self._cluster_config is not None:
@@ -311,17 +311,17 @@ def _build_rayjob_cr(self) -> Dict[str, Any]:
311311
return rayjob_cr
312312

313313
def _build_submitter_pod_template(
314-
self, files: Dict[str, str], configmap_name: str
314+
self, files: Dict[str, str], secret_name: str
315315
) -> Dict[str, Any]:
316316
"""
317-
Build submitterPodTemplate with ConfigMap volume mount for local files.
317+
Build submitterPodTemplate with Secret volume mount for local files.
318318
319319
If files contain working_dir.zip, an init container will unzip it before
320320
the main submitter container runs.
321321
322322
Args:
323323
files: Dict of file_name -> file_content
324-
configmap_name: Name of the ConfigMap containing the files
324+
secret_name: Name of the Secret containing the files
325325
326326
Returns:
327327
submitterPodTemplate specification
@@ -337,8 +337,8 @@ def _build_submitter_pod_template(
337337
):
338338
image = self._cluster_config.image
339339

340-
# Build ConfigMap items for each file
341-
config_map_items = []
340+
# Build Secret items for each file
341+
secret_items = []
342342
entrypoint_path = files.get(
343343
"__entrypoint_path__"
344344
) # Metadata for single file case
@@ -349,9 +349,9 @@ def _build_submitter_pod_template(
349349

350350
# For single file case, use the preserved path structure
351351
if entrypoint_path:
352-
config_map_items.append({"key": file_name, "path": entrypoint_path})
352+
secret_items.append({"key": file_name, "path": entrypoint_path})
353353
else:
354-
config_map_items.append({"key": file_name, "path": file_name})
354+
secret_items.append({"key": file_name, "path": file_name})
355355

356356
# Check if we need to unzip working_dir
357357
has_working_dir_zip = "working_dir.zip" in files
@@ -378,9 +378,9 @@ def _build_submitter_pod_template(
378378
"volumes": [
379379
{
380380
"name": "ray-job-files",
381-
"configMap": {
382-
"name": configmap_name,
383-
"items": config_map_items,
381+
"secret": {
382+
"secretName": secret_name,
383+
"items": secret_items,
384384
},
385385
}
386386
],

0 commit comments

Comments
 (0)