2424from 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
0 commit comments