Skip to content

Commit f9e4413

Browse files
committed
allow for custom CertGeneratorImage
1 parent 146b88d commit f9e4413

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

config/e2e/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ data:
77
kuberay:
88
rayDashboardOAuthEnabled: false
99
ingressDomain: "kind"
10+
certGeneratorImage: "quay.io/project-codeflare/ray:latest-py39-cu118"

main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func main() {
129129
RayDashboardOAuthEnabled: ptr.To(true),
130130
IngressDomain: "",
131131
MTLSEnabled: ptr.To(true),
132+
CertGeneratorImage: "quay.io/project-codeflare/ray:latest-py39-cu118",
132133
},
133134
}
134135

pkg/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ type KubeRayConfiguration struct {
3737
IngressDomain string `json:"ingressDomain"`
3838

3939
MTLSEnabled *bool `json:"mTLSEnabled,omitempty"`
40+
41+
CertGeneratorImage string `json:"certGeneratorImage"`
4042
}
4143

4244
type ControllerManager struct {

pkg/controllers/raycluster_webhook.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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), withContainerName(initContainerName))
90+
rayCluster.Spec.HeadGroupSpec.Template.Spec.InitContainers = upsert(rayCluster.Spec.HeadGroupSpec.Template.Spec.InitContainers, rayHeadInitContainer(rayCluster, w.Config.IngressDomain, w.Config.CertGeneratorImage), 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(), withContainerName(initContainerName))
120+
rayCluster.Spec.WorkerGroupSpecs[0].Template.Spec.InitContainers = upsert(rayCluster.Spec.WorkerGroupSpecs[0].Template.Spec.InitContainers, rayWorkerInitContainer(w.Config.CertGeneratorImage), 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)...)
165-
allErrors = append(allErrors, validateWorkerInitContainer(rayCluster)...)
164+
allErrors = append(allErrors, validateHeadInitContainer(rayCluster, w.Config.IngressDomain, w.Config.CertGeneratorImage)...)
165+
allErrors = append(allErrors, validateWorkerInitContainer(rayCluster, w.Config.CertGeneratorImage)...)
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) corev1.Container {
342+
func rayHeadInitContainer(rayCluster *rayv1.RayCluster, domain string, certGeneratorImage string) corev1.Container {
343343
rayClientRoute := "rayclient-" + rayCluster.Name + "-" + rayCluster.Namespace + "." + domain
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: "quay.io/project-codeflare/ray:latest-py39-cu118",
349+
Image: certGeneratorImage,
350350
Command: []string{
351351
"sh",
352352
"-c",
@@ -357,10 +357,10 @@ func rayHeadInitContainer(rayCluster *rayv1.RayCluster, domain string) corev1.Co
357357
return initContainerHead
358358
}
359359

360-
func rayWorkerInitContainer() corev1.Container {
360+
func rayWorkerInitContainer(certGeneratorImage string) corev1.Container {
361361
initContainerWorker := corev1.Container{
362362
Name: "create-cert",
363-
Image: "quay.io/project-codeflare/ray:latest-py39-cu118",
363+
Image: certGeneratorImage,
364364
Command: []string{
365365
"sh",
366366
"-c",
@@ -371,10 +371,10 @@ func rayWorkerInitContainer() corev1.Container {
371371
return initContainerWorker
372372
}
373373

374-
func validateHeadInitContainer(rayCluster *rayv1.RayCluster, domain string) field.ErrorList {
374+
func validateHeadInitContainer(rayCluster *rayv1.RayCluster, domain string, certGeneratorImage string) field.ErrorList {
375375
var allErrors field.ErrorList
376376

377-
if err := contains(rayCluster.Spec.HeadGroupSpec.Template.Spec.InitContainers, rayHeadInitContainer(rayCluster, domain), byContainerName,
377+
if err := contains(rayCluster.Spec.HeadGroupSpec.Template.Spec.InitContainers, rayHeadInitContainer(rayCluster, domain, certGeneratorImage), 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) fiel
383383
return allErrors
384384
}
385385

386-
func validateWorkerInitContainer(rayCluster *rayv1.RayCluster) field.ErrorList {
386+
func validateWorkerInitContainer(rayCluster *rayv1.RayCluster, certGeneratorImage string) field.ErrorList {
387387
var allErrors field.ErrorList
388388

389-
if err := contains(rayCluster.Spec.WorkerGroupSpecs[0].Template.Spec.InitContainers, rayWorkerInitContainer(), byContainerName,
389+
if err := contains(rayCluster.Spec.WorkerGroupSpecs[0].Template.Spec.InitContainers, rayWorkerInitContainer(certGeneratorImage), 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

Comments
 (0)