Skip to content

Commit

Permalink
make oauth image and cert generator image build time configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin <[email protected]>
  • Loading branch information
KPostOffice committed Jul 10, 2024
1 parent 677417b commit 565ae31
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ ifneq ($(shell git status --porcelain),)
BUILD_VERSION := $(BUILD_VERSION)-dirty
endif

OAUTH_IMAGE ?= registry.redhat.io/openshift4/ose-oauth-proxy:latest
CERT_GENERATOR_IMAGE ?= registry.redhat.io/ubi9:latest

.PHONY: all
all: build

Expand Down Expand Up @@ -167,6 +170,8 @@ build: fmt vet ## Build manager binary.
-ldflags " \
-X 'main.OperatorVersion=$(BUILD_VERSION)' \
-X 'main.BuildDate=$(BUILD_DATE)' \
-X 'controllers.CertGeneratorImage=$(CERT_GENERATOR_IMAGE)' \
-X 'controllers.OAuthProxyImage=$(OAUTH_IMAGE)' \
" \
-o bin/manager main.go

Expand All @@ -176,6 +181,8 @@ go-build-for-image: fmt vet ## Build manager binary.
-ldflags " \
-X 'main.OperatorVersion=$(BUILD_VERSION)' \
-X 'main.BuildDate=$(BUILD_DATE)' \
-X 'controllers.CertGeneratorImage=$(CERT_GENERATOR_IMAGE)' \
-X 'controllers.OAuthProxyImage=$(OAUTH_IMAGE)' \
" \
-tags strictfipsruntime -a -o manager main.go

Expand Down
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ func main() {
RayDashboardOAuthEnabled: ptr.To(true),
IngressDomain: "",
MTLSEnabled: ptr.To(true),
CertGeneratorImage: "registry.redhat.io/ubi9@sha256:770cf07083e1c85ae69c25181a205b7cdef63c11b794c89b3b487d4670b4c328",
},
AppWrapper: &config.AppWrapperConfiguration{
Enabled: ptr.To(false),
Expand Down
2 changes: 0 additions & 2 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ type KubeRayConfiguration struct {
IngressDomain string `json:"ingressDomain"`

MTLSEnabled *bool `json:"mTLSEnabled,omitempty"`

CertGeneratorImage string `json:"certGeneratorImage"`
}

type ControllerManager struct {
Expand Down
6 changes: 3 additions & 3 deletions pkg/controllers/raycluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func validateHeadGroupServiceAccountName(rayCluster *rayv1.RayCluster) field.Err
func oauthProxyContainer(rayCluster *rayv1.RayCluster) corev1.Container {
return corev1.Container{
Name: oauthProxyContainerName,
Image: "registry.redhat.io/openshift4/ose-oauth-proxy@sha256:1ea6a01bf3e63cdcf125c6064cbd4a4a270deaf0f157b3eabb78f60556840366",
Image: OAuthProxyImage,
Ports: []corev1.ContainerPort{
{ContainerPort: 8443, Name: "oauth-proxy"},
},
Expand Down Expand Up @@ -349,7 +349,7 @@ func rayHeadInitContainer(rayCluster *rayv1.RayCluster, config *config.KubeRayCo

initContainerHead := corev1.Container{
Name: "create-cert",
Image: config.CertGeneratorImage,
Image: CertGeneratorImage,
Command: []string{
"sh",
"-c",
Expand All @@ -363,7 +363,7 @@ func rayHeadInitContainer(rayCluster *rayv1.RayCluster, config *config.KubeRayCo
func rayWorkerInitContainer(config *config.KubeRayConfiguration) corev1.Container {
initContainerWorker := corev1.Container{
Name: "create-cert",
Image: config.CertGeneratorImage,
Image: CertGeneratorImage,
Command: []string{
"sh",
"-c",
Expand Down
4 changes: 2 additions & 2 deletions pkg/controllers/raycluster_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func TestValidateCreate(t *testing.T) {
Containers: []corev1.Container{
{
Name: oauthProxyContainerName,
Image: "registry.redhat.io/openshift4/ose-oauth-proxy@sha256:1ea6a01bf3e63cdcf125c6064cbd4a4a270deaf0f157b3eabb78f60556840366",
Image: OAuthProxyImage,
Ports: []corev1.ContainerPort{
{ContainerPort: 8443, Name: "oauth-proxy"},
},
Expand Down Expand Up @@ -363,7 +363,7 @@ func TestValidateUpdate(t *testing.T) {
Containers: []corev1.Container{
{
Name: oauthProxyContainerName,
Image: "registry.redhat.io/openshift4/ose-oauth-proxy@sha256:1ea6a01bf3e63cdcf125c6064cbd4a4a270deaf0f157b3eabb78f60556840366",
Image: OAuthProxyImage,
Ports: []corev1.ContainerPort{
{ContainerPort: 8443, Name: "oauth-proxy"},
},
Expand Down
5 changes: 5 additions & 0 deletions pkg/controllers/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import (
routeapply "github.com/openshift/client-go/route/applyconfigurations/route/v1"
)

var (
CertGeneratorImage = ""
OAuthProxyImage = ""
)

func serviceNameFromCluster(cluster *rayv1.RayCluster) string {
return cluster.Name + "-head-svc"
}
Expand Down
2 changes: 1 addition & 1 deletion test/odh/resources/custom-nb-small.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: registry.redhat.io/openshift4/ose-oauth-proxy:v4.10
image: registry.redhat.io/openshift4/ose-oauth-proxy:latest
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
Expand Down

0 comments on commit 565ae31

Please sign in to comment.