@@ -87,7 +87,7 @@ func (w *rayClusterWebhook) Default(ctx context.Context, obj runtime.Object) err
8787 }
8888
8989 // Append the create-cert Init Container
90- rayCluster .Spec .HeadGroupSpec .Template .Spec .InitContainers = upsert (rayCluster .Spec .HeadGroupSpec .Template .Spec .InitContainers , rayHeadInitContainer (rayCluster , w .Config . IngressDomain , w . Config . CertGeneratorImage ), withContainerName (initContainerName ))
90+ rayCluster .Spec .HeadGroupSpec .Template .Spec .InitContainers = upsert (rayCluster .Spec .HeadGroupSpec .Template .Spec .InitContainers , rayHeadInitContainer (rayCluster , w .Config ), withContainerName (initContainerName ))
9191
9292 // Append the CA volumes
9393 for _ , caVol := range caVolumes (rayCluster ) {
@@ -117,7 +117,7 @@ func (w *rayClusterWebhook) Default(ctx context.Context, obj runtime.Object) err
117117 }
118118
119119 // Append the create-cert Init Container
120- rayCluster .Spec .WorkerGroupSpecs [0 ].Template .Spec .InitContainers = upsert (rayCluster .Spec .WorkerGroupSpecs [0 ].Template .Spec .InitContainers , rayWorkerInitContainer (w .Config . CertGeneratorImage ), withContainerName (initContainerName ))
120+ rayCluster .Spec .WorkerGroupSpecs [0 ].Template .Spec .InitContainers = upsert (rayCluster .Spec .WorkerGroupSpecs [0 ].Template .Spec .InitContainers , rayWorkerInitContainer (w .Config ), withContainerName (initContainerName ))
121121 }
122122
123123 return nil
@@ -161,8 +161,8 @@ func (w *rayClusterWebhook) ValidateUpdate(ctx context.Context, oldObj, newObj r
161161
162162 // Init Container related errors
163163 if ptr .Deref (w .Config .MTLSEnabled , true ) {
164- allErrors = append (allErrors , validateHeadInitContainer (rayCluster , w .Config . IngressDomain , w . Config . CertGeneratorImage )... )
165- allErrors = append (allErrors , validateWorkerInitContainer (rayCluster , w .Config . CertGeneratorImage )... )
164+ allErrors = append (allErrors , validateHeadInitContainer (rayCluster , w .Config )... )
165+ allErrors = append (allErrors , validateWorkerInitContainer (rayCluster , w .Config )... )
166166 allErrors = append (allErrors , validateHeadEnvVars (rayCluster )... )
167167 allErrors = append (allErrors , validateWorkerEnvVars (rayCluster )... )
168168 allErrors = append (allErrors , validateCaVolumes (rayCluster )... )
@@ -339,14 +339,14 @@ func caVolumes(rayCluster *rayv1.RayCluster) []corev1.Volume {
339339 }
340340}
341341
342- func rayHeadInitContainer (rayCluster * rayv1.RayCluster , domain string , certGeneratorImage string ) corev1.Container {
343- rayClientRoute := "rayclient-" + rayCluster .Name + "-" + rayCluster .Namespace + "." + domain
342+ func rayHeadInitContainer (rayCluster * rayv1.RayCluster , config * config. KubeRayConfiguration ) corev1.Container {
343+ rayClientRoute := "rayclient-" + rayCluster .Name + "-" + rayCluster .Namespace + "." + config . IngressDomain
344344 // Service name for basic interactive
345345 svcDomain := rayCluster .Name + "-head-svc." + rayCluster .Namespace + ".svc"
346346
347347 initContainerHead := corev1.Container {
348348 Name : "create-cert" ,
349- Image : certGeneratorImage ,
349+ Image : config . CertGeneratorImage ,
350350 Command : []string {
351351 "sh" ,
352352 "-c" ,
@@ -357,10 +357,10 @@ func rayHeadInitContainer(rayCluster *rayv1.RayCluster, domain string, certGener
357357 return initContainerHead
358358}
359359
360- func rayWorkerInitContainer (certGeneratorImage string ) corev1.Container {
360+ func rayWorkerInitContainer (config * config. KubeRayConfiguration ) corev1.Container {
361361 initContainerWorker := corev1.Container {
362362 Name : "create-cert" ,
363- Image : certGeneratorImage ,
363+ Image : config . CertGeneratorImage ,
364364 Command : []string {
365365 "sh" ,
366366 "-c" ,
@@ -371,10 +371,10 @@ func rayWorkerInitContainer(certGeneratorImage string) corev1.Container {
371371 return initContainerWorker
372372}
373373
374- func validateHeadInitContainer (rayCluster * rayv1.RayCluster , domain string , certGeneratorImage string ) field.ErrorList {
374+ func validateHeadInitContainer (rayCluster * rayv1.RayCluster , config * config. KubeRayConfiguration ) field.ErrorList {
375375 var allErrors field.ErrorList
376376
377- if err := contains (rayCluster .Spec .HeadGroupSpec .Template .Spec .InitContainers , rayHeadInitContainer (rayCluster , domain , certGeneratorImage ), byContainerName ,
377+ if err := contains (rayCluster .Spec .HeadGroupSpec .Template .Spec .InitContainers , rayHeadInitContainer (rayCluster , config ), byContainerName ,
378378 field .NewPath ("spec" , "headGroupSpec" , "template" , "spec" , "initContainers" ),
379379 "create-cert Init Container is immutable" ); err != nil {
380380 allErrors = append (allErrors , err )
@@ -383,10 +383,10 @@ func validateHeadInitContainer(rayCluster *rayv1.RayCluster, domain string, cert
383383 return allErrors
384384}
385385
386- func validateWorkerInitContainer (rayCluster * rayv1.RayCluster , certGeneratorImage string ) field.ErrorList {
386+ func validateWorkerInitContainer (rayCluster * rayv1.RayCluster , config * config. KubeRayConfiguration ) field.ErrorList {
387387 var allErrors field.ErrorList
388388
389- if err := contains (rayCluster .Spec .WorkerGroupSpecs [0 ].Template .Spec .InitContainers , rayWorkerInitContainer (certGeneratorImage ), byContainerName ,
389+ if err := contains (rayCluster .Spec .WorkerGroupSpecs [0 ].Template .Spec .InitContainers , rayWorkerInitContainer (config ), byContainerName ,
390390 field .NewPath ("spec" , "workerGroupSpecs" , "0" , "template" , "spec" , "initContainers" ),
391391 "create-cert Init Container is immutable" ); err != nil {
392392 allErrors = append (allErrors , err )
0 commit comments