diff --git a/manifests/cluster-authentication-operator_03_version-mapping.yaml b/manifests/cluster-authentication-operator_03_version-mapping.yaml deleted file mode 100644 index d102573729..0000000000 --- a/manifests/cluster-authentication-operator_03_version-mapping.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - namespace: openshift-authentication-operator - name: version-mapping -data: - "0.0.1-snapshot_openshift": "quay.io/openshift/origin-hypershift:v4.0" - "0.0.1-snapshot": "quay.io/openshift/origin-cluster-authentication-operator:v4.0" diff --git a/manifests/cluster-authentication-operator_05_deploy.yaml b/manifests/cluster-authentication-operator_05_deploy.yaml index 97733c68c4..21ed8d8484 100644 --- a/manifests/cluster-authentication-operator_05_deploy.yaml +++ b/manifests/cluster-authentication-operator_05_deploy.yaml @@ -37,6 +37,8 @@ spec: value: quay.io/openshift/origin-hypershift:v4.0 - name: OPERATOR_IMAGE_VERSION value: "0.0.1-snapshot" + - name: OPERAND_IMAGE_VERSION + value: "0.0.1-snapshot_openshift" - name: POD_NAME valueFrom: fieldRef: diff --git a/pkg/operator2/deployment.go b/pkg/operator2/deployment.go index 04fd1dcf2b..58f2be6780 100644 --- a/pkg/operator2/deployment.go +++ b/pkg/operator2/deployment.go @@ -4,7 +4,6 @@ import ( "crypto/sha512" "encoding/base64" "fmt" - "os" "strings" operatorv1 "github.com/openshift/api/operator/v1" @@ -106,7 +105,7 @@ func defaultDeployment( SecurityContext: &corev1.PodSecurityContext{}, Containers: []corev1.Container{ { - Image: os.Getenv("IMAGE"), + Image: osinImage, ImagePullPolicy: corev1.PullPolicy("IfNotPresent"), Name: targetName, Command: []string{ diff --git a/pkg/operator2/operator.go b/pkg/operator2/operator.go index 0b0871b910..9305dcc6fc 100644 --- a/pkg/operator2/operator.go +++ b/pkg/operator2/operator.go @@ -45,9 +45,13 @@ const ( targetName = "openshift-authentication" targetNameOperator = "openshift-authentication-operator" globalConfigName = "cluster" - osinOperandName = "integrated-oauth-server" + operatorSelfName = "operator" + osinOperandName = "integrated-oauth-server" operatorVersionEnvName = "OPERATOR_IMAGE_VERSION" + operandVersionEnvName = "OPERAND_IMAGE_VERSION" + operandImageEnvName = "IMAGE" + apiHostEnvName = "KUBERNETES_SERVICE_HOST" machineConfigNamespace = "openshift-config-managed" userConfigNamespace = "openshift-config" @@ -113,6 +117,16 @@ const ( containerPort = 6443 ) +// static environment variables from operator deployment +var ( + osinImage = os.Getenv(operandImageEnvName) + osinVersion = os.Getenv(operandVersionEnvName) + + operatorVersion = os.Getenv(operatorVersionEnvName) + + apiserverURL = os.Getenv(apiHostEnvName) +) + type authOperator struct { authOperatorConfigClient OperatorClient @@ -359,9 +373,8 @@ func (c *authOperator) handleSync(operatorConfig *operatorv1.Authentication) err if ready { // Set current version and available status - version := os.Getenv(operatorVersionEnvName) - if c.versionGetter.GetVersions()["operator"] != version { - c.versionGetter.SetVersion("operator", version) + if c.versionGetter.GetVersions()[operatorSelfName] != operatorVersion { + c.versionGetter.SetVersion(operatorSelfName, operatorVersion) } c.setAvailableStatus(operatorConfig) } @@ -390,7 +403,6 @@ func (c *authOperator) checkReady( } // when the deployment is ready, set its version for the operator - osinVersion := status.VersionForOperand(targetNameOperator, os.Getenv("IMAGE"), c.configMaps, c.recorder) if c.versionGetter.GetVersions()[osinOperandName] != osinVersion { c.versionGetter.SetVersion(osinOperandName, osinVersion) } @@ -497,7 +509,6 @@ func (c *authOperator) checkWellknownEndpointReady(authConfig *configv1.Authenti return false, "", fmt.Errorf("failed to build transport for SA ca.crt: %v", err) } - apiserverURL := os.Getenv("KUBERNETES_SERVICE_HOST") wellKnown := "https://" + apiserverURL + oauthMetadataAPIEndpoint req, err := http.NewRequest(http.MethodGet, wellKnown, nil)