THIS IS ONLY A TEST INSTANCE. DON'T DO IMPORTANT WORK HERE!

Unverified Commit e9c5d3f3 authored by Oleksandr Andriienko's avatar Oleksandr Andriienko Committed by GitHub
Browse files

feat: Remove image refs in `defaults.go` and replace by env vars (#172)



* Move image related default variables to the operator env.
Signed-off-by: default avatarOleksandr Andriienko <oandriie@redhat.com>

* Fix tests.
Signed-off-by: default avatarOleksandr Andriienko <oandriie@redhat.com>

* Use the same env name for CRW and Upstream Che
Signed-off-by: default avatarOleksandr Andriienko <oandriie@redhat.com>

* Clean up.
Signed-off-by: default avatarOleksandr Andriienko <oandriie@redhat.com>

* Improve most che-operator env names
Signed-off-by: default avatarOleksandr Andriienko <oandriie@redhat.com>

* Use cheImage instead of repo only in the envs. Rename cheImageTag to cheVersion.
Signed-off-by: default avatarOleksandr Andriienko <oandriie@redhat.com>

* Add forgotten che-image tag to IMAGE_default_che_server
Signed-off-by: default avatarOleksandr Andriienko <oandriie@redhat.com>

* Add some logic for back compatibilty with Che 7.8.0
Signed-off-by: default avatarOleksandr Andriienko <oandriie@redhat.com>

* Handle one of the realese scripts.
Signed-off-by: default avatarOleksandr Andriienko <oandriie@redhat.com>

* Fix GetFullCheServerImageLink
Signed-off-by: default avatarAnatoliy Bazko <abazko@redhat.com>

* Remove extra_images.go
Signed-off-by: default avatarAnatoliy Bazko <abazko@redhat.com>

* Fix tests
Signed-off-by: default avatarAnatoliy Bazko <abazko@redhat.com>

* Improve release scripts.
Signed-off-by: default avatarOleksandr Andriienko <oandriie@redhat.com>

* Add docker images env to operator-local.yaml
Signed-off-by: default avatarflacatus <flacatus@redhat.com>

* Che 15874 - fix wrong docker images and update olm files (#174)

* Fix wrong docker images values

The docker images set in this GH repo should be the upstream ones,
not the CRW ones
Signed-off-by: default avatarDavid Festal <dfestal@redhat.com>
Co-authored-by: default avatarAnatolii Bazko <abazko@redhat.com>
Co-authored-by: default avatarFlavius Lacatusu <59865209+flacatus@users.noreply.github.com>
Co-authored-by: default avatarDavid Festal <dfestal@redhat.com>
parent 41f00fff
......@@ -23,6 +23,7 @@ import (
"runtime"
"github.com/eclipse/che-operator/pkg/apis"
"github.com/eclipse/che-operator/pkg/deploy"
"github.com/eclipse/che-operator/pkg/controller"
"github.com/operator-framework/operator-sdk/pkg/leader"
"github.com/operator-framework/operator-sdk/pkg/ready"
......@@ -75,6 +76,7 @@ func printVersion() {
func main() {
flag.Parse()
deploy.InitDefaultsFromEnv()
//logf.SetLogger(logf.ZapLogger(false))
printVersion()
namespace, err := k8sutil.GetWatchNamespace()
......
......@@ -54,3 +54,24 @@ spec:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: "che-operator"
- name: CHE_VERSION
value: "7.8.0"
- name: IMAGE_default_che_server
value: "quay.io/eclipse/che-server:7.8.0"
- name: IMAGE_default_plugin_registry
value: "quay.io/eclipse/che-plugin-registry:7.8.0"
- name: IMAGE_default_devfile_registry
value: "quay.io/eclipse/che-devfile-registry:7.8.0"
- name: "IMAGE_default_pvc_jobs"
value: "registry.access.redhat.com/ubi8-minimal:8.0-213"
- name: "IMAGE_default_postgres"
value: "centos/postgresql-96-centos7:9.6"
- name: "IMAGE_default_keycloak"
value: "quay.io/eclipse/che-keycloak:7.8.0"
- name: "IMAGE_default_che_workspace_plugin_broker_metadata"
value: "quay.io/eclipse/che-plugin-metadata-broker:v3.1.0"
- name: "IMAGE_default_che_workspace_plugin_broker_artifacts"
value: "quay.io/eclipse/che-plugin-artifacts-broker:v3.1.0"
- name: "IMAGE_default_che_server_secure_exposer_jwt_proxy_image"
value: "quay.io/eclipse/che-jwtproxy:dbd0578"
......@@ -53,6 +53,26 @@ spec:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: "che-operator"
- name: CHE_VERSION
value: "7.8.0"
- name: IMAGE_default_che_server
value: "quay.io/eclipse/che-server:7.8.0"
- name: IMAGE_default_plugin_registry
value: "quay.io/eclipse/che-plugin-registry:7.8.0"
- name: IMAGE_default_devfile_registry
value: "quay.io/eclipse/che-devfile-registry:7.8.0"
- name: "IMAGE_default_pvc_jobs"
value: "registry.access.redhat.com/ubi8-minimal:8.0-213"
- name: "IMAGE_default_postgres"
value: "centos/postgresql-96-centos7:9.6"
- name: "IMAGE_default_keycloak"
value: "quay.io/eclipse/che-keycloak:7.8.0"
- name: "IMAGE_default_che_workspace_plugin_broker_metadata"
value: "quay.io/eclipse/che-plugin-metadata-broker:v3.1.0"
- name: "IMAGE_default_che_workspace_plugin_broker_artifacts"
value: "quay.io/eclipse/che-plugin-artifacts-broker:v3.1.0"
- name: "IMAGE_default_che_server_secure_exposer_jwt_proxy_image"
value: "quay.io/eclipse/che-jwtproxy:dbd0578"
restartPolicy: Always
serviceAccountName: che-operator
terminationGracePeriodSeconds: 5
......@@ -97,22 +97,53 @@ releaseOperatorCode() {
set -e
if [[ $result == 0 ]]; then
local defaultsgo=$BASE_DIR/pkg/deploy/defaults.go
local extraimagesgo=$BASE_DIR/pkg/deploy/extra_images.go
local operatoryaml=$BASE_DIR/deploy/operator.yaml
echo -e $GREEN"3.1 Launch 'release-operator-code.sh' script"$NC
. ${BASE_DIR}/release-operator-code.sh $RELEASE
echo -e $GREEN"3.2 Validate changes for $defaultsgo"$NC
[[ \"$RELEASE\" != $(getPropertyValue $defaultsgo defaultCheServerImageTag) ]] && { echo -e $RED"$defaultsgo cotains unexpected changes"$NC; exit 1; }
[[ \"quay.io/eclipse/che-devfile-registry:$RELEASE\" != $(getPropertyValue $defaultsgo defaultDevfileRegistryUpstreamImage) ]] && { echo -e $RED"$defaultsgo cotains unexpected changes"$NC; exit 1; }
[[ \"quay.io/eclipse/che-plugin-registry:$RELEASE\" != $(getPropertyValue $defaultsgo defaultPluginRegistryUpstreamImage) ]] && { echo -e $RED"$defaultsgo cotains unexpected changes"$NC; exit 1; }
[[ \"quay.io/eclipse/che-keycloak:$RELEASE\" != $(getPropertyValue $defaultsgo defaultKeycloakUpstreamImage) ]] && { echo -e $RED"$defaultsgo cotains unexpected changes"$NC; exit 1; }
echo -e $GREEN"3.2 Validate changes for $operatoryaml"$NC
echo -e $GREEN"3.3 Validate changes for $extraimagesgo"$NC
[[ \"\" == $(getPropertyValue $extraimagesgo defaultCheWorkspacePluginBrokerMetadataUpstreamImage) ]] && { echo $RED"$extraimagesgo cotains unexpected changes"$NC; exit 1; }
[[ \"\" == $(getPropertyValue $extraimagesgo defaultCheWorkspacePluginBrokerArtifactsUpstreamImage) ]] && { echo $RED"$extraimagesgo cotains unexpected changes"$NC; exit 1; }
[[ \"\" == $(getPropertyValue $extraimagesgo defaultCheServerSecureExposerJwtProxyUpstreamImage) ]] && { echo $RED"$extraimagesgo cotains unexpected changes"$NC; exit 1; }
if ! grep -q "value: ${RELEASE}" $operatoryaml; then
echo -e $RED" Unable to find Che version ${RELEASE} in the $operatoryaml"$NC; exit 1
fi
if ! grep -q "value: quay.io/eclipse/che-server:$RELEASE" $operatoryaml; then
echo -e $RED" Unable to find Che server image with version ${RELEASE} in the $operatoryaml"$NC; exit 1
fi
if ! grep -q "value: quay.io/eclipse/che-plugin-registry:$RELEASE" $operatoryaml; then
echo -e $RED" Unable to find plugin registry image with version ${RELEASE} in the $operatoryaml"$NC; exit 1
fi
if ! grep -q "value: quay.io/eclipse/che-devfile-registry:$RELEASE" $operatoryaml; then
echo -e $RED" Unable to find devfile registry image with version ${RELEASE} in the $operatoryaml"$NC; exit 1
fi
if ! grep -q "value: quay.io/eclipse/che-keycloak:$RELEASE" $operatoryaml; then
echo -e $RED" Unable to find che-keycloak image with version ${RELEASE} in the $operatoryaml"$NC; exit 1
fi
wget https://raw.githubusercontent.com/eclipse/che/${RELEASE}/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties -q -O /tmp/che.properties
plugin_broker_meta_image=$(cat /tmp/che.properties | grep che.workspace.plugin_broker.metadata.image | cut -d '=' -f2)
if ! grep -q "value: $plugin_broker_meta_image" $operatoryaml; then
echo -e $RED" Unable to find plugin broker meta image '$plugin_broker_meta_image' in the $operatoryaml"$NC; exit 1
fi
plugin_broker_artifacts_image=$(cat /tmp/che.properties | grep che.workspace.plugin_broker.artifacts.image | cut -d '=' -f2)
if ! grep -q "value: $plugin_broker_artifacts_image" $operatoryaml; then
echo -e $RED" Unable to find plugin broker artifacts image '$plugin_broker_artifacts_image' in the $operatoryaml"$NC; exit 1
fi
jwt_proxy_image=$(cat /tmp/che.properties | grep che.server.secure_exposer.jwtproxy.image | cut -d '=' -f2)
if ! grep -q "value: $jwt_proxy_image" $operatoryaml; then
echo -e $RED" Unable to find jwt proxy image $jwt_proxy_image in the $operatoryaml"$NC; exit 1
fi
echo -e $GREEN"3.3 It is needed to check file manully"$NC
echo $operatoryaml
read -p "Press enter to continue"
echo -e $GREEN"3.4 Validate number of changed files"$NC
local changes=$(git status -s | wc -l)
......
--- /home/dfestal/go/src/github.com/eclipse/che-operator/olm/eclipse-che-preview-kubernetes/deploy/olm-catalog/eclipse-che-preview-kubernetes/9.9.9-nightly.1580283700/eclipse-che-preview-kubernetes.v9.9.9-nightly.1580283700.clusterserviceversion.yaml 2020-02-04 15:17:25.000000000 +0100
+++ /home/dfestal/go/src/github.com/eclipse/che-operator/olm/eclipse-che-preview-kubernetes/deploy/olm-catalog/eclipse-che-preview-kubernetes/9.9.9-nightly.1581975496/eclipse-che-preview-kubernetes.v9.9.9-nightly.1581975496.clusterserviceversion.yaml 2020-02-17 22:38:16.000000000 +0100
@@ -49,12 +49,12 @@
categories: Developer Tools
certified: "false"
containerImage: quay.io/eclipse/che-operator:nightly
- createdAt: "2020-01-29T07:41:40Z"
+ createdAt: "2020-02-17T21:38:16Z"
description: A Kube-native development solution that delivers portable and collaborative
developer workspaces.
repository: https://github.com/eclipse/che-operator
support: Eclipse Foundation
- name: eclipse-che-preview-kubernetes.v9.9.9-nightly.1580283700
+ name: eclipse-che-preview-kubernetes.v9.9.9-nightly.1581975496
namespace: placeholder
spec:
apiservicedefinitions: {}
@@ -247,6 +247,26 @@
fieldPath: metadata.name
- name: OPERATOR_NAME
value: che-operator
+ - name: CHE_VERSION
+ value: 7.8.0
+ - name: IMAGE_default_che_server
+ value: quay.io/eclipse/che-server:7.8.0
+ - name: IMAGE_default_plugin_registry
+ value: quay.io/eclipse/che-plugin-registry:7.8.0
+ - name: IMAGE_default_devfile_registry
+ value: quay.io/eclipse/che-devfile-registry:7.8.0
+ - name: IMAGE_default_pvc_jobs
+ value: registry.access.redhat.com/ubi8-minimal:8.0-213
+ - name: IMAGE_default_postgres
+ value: centos/postgresql-96-centos7:9.6
+ - name: IMAGE_default_keycloak
+ value: quay.io/eclipse/che-keycloak:7.8.0
+ - name: IMAGE_default_che_workspace_plugin_broker_metadata
+ value: quay.io/eclipse/che-plugin-metadata-broker:v3.1.0
+ - name: IMAGE_default_che_workspace_plugin_broker_artifacts
+ value: quay.io/eclipse/che-plugin-artifacts-broker:v3.1.0
+ - name: IMAGE_default_che_server_secure_exposer_jwt_proxy_image
+ value: quay.io/eclipse/che-jwtproxy:dbd0578
image: quay.io/eclipse/che-operator:nightly
imagePullPolicy: Always
name: che-operator
@@ -350,5 +370,5 @@
maturity: stable
provider:
name: Eclipse Foundation
- replaces: eclipse-che-preview-kubernetes.v9.9.9-nightly.1578737756
- version: 9.9.9-nightly.1580283700
+ replaces: eclipse-che-preview-kubernetes.v9.9.9-nightly.1580283700
+ version: 9.9.9-nightly.1581975496
channels:
- currentCSV: eclipse-che-preview-kubernetes.v9.9.9-nightly.1580283700
- currentCSV: eclipse-che-preview-kubernetes.v9.9.9-nightly.1581975496
name: nightly
- currentCSV: eclipse-che-preview-kubernetes.v7.8.0
name: stable
......
--- /home/dfestal/go/src/github.com/eclipse/che-operator/olm/eclipse-che-preview-openshift/deploy/olm-catalog/eclipse-che-preview-openshift/9.9.9-nightly.1580283700/eclipse-che-preview-openshift.v9.9.9-nightly.1580283700.clusterserviceversion.yaml 2020-02-04 15:17:25.000000000 +0100
+++ /home/dfestal/go/src/github.com/eclipse/che-operator/olm/eclipse-che-preview-openshift/deploy/olm-catalog/eclipse-che-preview-openshift/9.9.9-nightly.1581975497/eclipse-che-preview-openshift.v9.9.9-nightly.1581975497.clusterserviceversion.yaml 2020-02-17 22:38:17.000000000 +0100
@@ -46,12 +46,12 @@
categories: Developer Tools, OpenShift Optional
certified: "false"
containerImage: quay.io/eclipse/che-operator:nightly
- createdAt: "2020-01-29T07:41:40Z"
+ createdAt: "2020-02-17T21:38:17Z"
description: A Kube-native development solution that delivers portable and collaborative
developer workspaces in OpenShift.
repository: https://github.com/eclipse/che-operator
support: Eclipse Foundation
- name: eclipse-che-preview-openshift.v9.9.9-nightly.1580283700
+ name: eclipse-che-preview-openshift.v9.9.9-nightly.1581975497
namespace: placeholder
spec:
apiservicedefinitions: {}
@@ -287,6 +287,26 @@
fieldPath: metadata.name
- name: OPERATOR_NAME
value: che-operator
+ - name: CHE_VERSION
+ value: 7.8.0
+ - name: IMAGE_default_che_server
+ value: quay.io/eclipse/che-server:7.8.0
+ - name: IMAGE_default_plugin_registry
+ value: quay.io/eclipse/che-plugin-registry:7.8.0
+ - name: IMAGE_default_devfile_registry
+ value: quay.io/eclipse/che-devfile-registry:7.8.0
+ - name: IMAGE_default_pvc_jobs
+ value: registry.access.redhat.com/ubi8-minimal:8.0-213
+ - name: IMAGE_default_postgres
+ value: centos/postgresql-96-centos7:9.6
+ - name: IMAGE_default_keycloak
+ value: quay.io/eclipse/che-keycloak:7.8.0
+ - name: IMAGE_default_che_workspace_plugin_broker_metadata
+ value: quay.io/eclipse/che-plugin-metadata-broker:v3.1.0
+ - name: IMAGE_default_che_workspace_plugin_broker_artifacts
+ value: quay.io/eclipse/che-plugin-artifacts-broker:v3.1.0
+ - name: IMAGE_default_che_server_secure_exposer_jwt_proxy_image
+ value: quay.io/eclipse/che-jwtproxy:dbd0578
image: quay.io/eclipse/che-operator:nightly
imagePullPolicy: Always
name: che-operator
@@ -395,5 +415,5 @@
maturity: stable
provider:
name: Eclipse Foundation
- replaces: eclipse-che-preview-openshift.v9.9.9-nightly.1578737756
- version: 9.9.9-nightly.1580283700
+ replaces: eclipse-che-preview-openshift.v9.9.9-nightly.1580283700
+ version: 9.9.9-nightly.1581975497
channels:
- currentCSV: eclipse-che-preview-openshift.v9.9.9-nightly.1580283700
- currentCSV: eclipse-che-preview-openshift.v9.9.9-nightly.1581975497
name: nightly
- currentCSV: eclipse-che-preview-openshift.v7.8.0
name: stable
......
......@@ -14,6 +14,7 @@ package che
import (
"context"
"fmt"
"strings"
"time"
orgv1 "github.com/eclipse/che-operator/pkg/apis/org/v1"
......@@ -470,7 +471,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
}
}
desiredImage := util.GetValue(instance.Spec.Database.PostgresImage, deploy.DefaultPostgresImage(instance, cheFlavor))
desiredImage := util.GetValue(instance.Spec.Database.PostgresImage, deploy.DefaultPostgresImage(instance))
effectiveImage := pgDeployment.Spec.Template.Spec.Containers[0].Image
desiredImagePullPolicy := util.GetValue(string(instance.Spec.Database.PostgresImagePullPolicy), deploy.DefaultPullPolicyFromDockerImage(desiredImage))
effectiveImagePullPolicy := string(pgDeployment.Spec.Template.Spec.Containers[0].ImagePullPolicy)
......@@ -646,7 +647,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
k8sclient.GetDeploymentRollingUpdateStatus("keycloak", instance.Namespace)
}
desiredImage := util.GetValue(instance.Spec.Auth.IdentityProviderImage, deploy.DefaultKeycloakImage(instance, cheFlavor))
desiredImage := util.GetValue(instance.Spec.Auth.IdentityProviderImage, deploy.DefaultKeycloakImage(instance))
effectiveImage := effectiveKeycloakDeployment.Spec.Template.Spec.Containers[0].Image
desiredImagePullPolicy := util.GetValue(string(instance.Spec.Auth.IdentityProviderImagePullPolicy), deploy.DefaultPullPolicyFromDockerImage(desiredImage))
effectiveImagePullPolicy := string(effectiveKeycloakDeployment.Spec.Template.Spec.Containers[0].ImagePullPolicy)
......@@ -874,7 +875,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
}
}
devfileRegistryImage := util.GetValue(instance.Spec.Server.DevfileRegistryImage, deploy.DefaultDevfileRegistryImage(instance, cheFlavor))
devfileRegistryImage := util.GetValue(instance.Spec.Server.DevfileRegistryImage, deploy.DefaultDevfileRegistryImage(instance))
result, err := addRegistryDeployment(
"devfile",
devfileRegistryImage,
......@@ -945,7 +946,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
pluginRegistryURL = guessedPluginRegistryURL
}
pluginRegistryImage := util.GetValue(instance.Spec.Server.PluginRegistryImage, deploy.DefaultPluginRegistryImage(instance, cheFlavor))
pluginRegistryImage := util.GetValue(instance.Spec.Server.PluginRegistryImage, deploy.DefaultPluginRegistryImage(instance))
result, err := addRegistryDeployment(
"plugin",
pluginRegistryImage,
......@@ -978,10 +979,12 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
// configMap resource version will be an env in Che deployment to easily update it when a ConfigMap changes
// which will automatically trigger Che rolling update
cmResourceVersion := cheConfigMap.ResourceVersion
cheImageAndTag := GetFullCheServerImageLink(instance)
cheVersion := EvaluateCheServerVersion(instance)
// create Che deployment
cheImageRepo := util.GetValue(instance.Spec.Server.CheImage, deploy.DefaultCheServerImageRepo(instance, cheFlavor))
cheImageTag := util.GetValue(instance.Spec.Server.CheImageTag, deploy.DefaultCheServerImageTag(cheFlavor))
cheDeploymentToCreate, err := deploy.NewCheDeployment(instance, cheImageRepo, cheImageTag, cmResourceVersion, isOpenShift)
cheDeploymentToCreate, err := deploy.NewCheDeployment(instance, cheImageAndTag, cmResourceVersion, isOpenShift)
if err != nil {
return reconcile.Result{}, err
}
......@@ -1030,9 +1033,9 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
instance, _ = r.GetCR(request)
return reconcile.Result{Requeue: true, RequeueAfter: time.Second * 1}, err
}
if instance.Status.CheVersion != cheImageTag {
instance.Status.CheVersion = cheImageTag
if err := r.UpdateCheCRStatus(instance, "version", cheImageTag); err != nil {
if instance.Status.CheVersion != cheVersion {
instance.Status.CheVersion = cheVersion
if err := r.UpdateCheCRStatus(instance, "version", cheVersion); err != nil {
instance, _ = r.GetCR(request)
return reconcile.Result{Requeue: true, RequeueAfter: time.Second * 1}, err
}
......@@ -1051,9 +1054,9 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
if err := controllerutil.SetControllerReference(instance, cheDeploymentToCreate, r.scheme); err != nil {
logrus.Errorf("An error occurred: %s", err)
}
logrus.Infof("Updating %s %s with image %s:%s", cheDeploymentToCreate.Name, cheDeploymentToCreate.Kind, cheImageRepo, cheImageTag)
instance.Status.CheVersion = cheImageTag
if err := r.UpdateCheCRStatus(instance, "version", cheImageTag); err != nil {
logrus.Infof("Updating %s %s with image %s", cheDeploymentToCreate.Name, cheDeploymentToCreate.Kind, cheImageAndTag)
instance.Status.CheVersion = cheVersion
if err := r.UpdateCheCRStatus(instance, "version", cheVersion); err != nil {
instance, _ = r.GetCR(request)
return reconcile.Result{Requeue: true, RequeueAfter: time.Second * 1}, err
}
......@@ -1130,7 +1133,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
time.Sleep(time.Duration(1) * time.Second)
cm := r.GetEffectiveConfigMap(instance, cheConfigMap.Name)
cmResourceVersion := cm.ResourceVersion
cheDeployment, err := deploy.NewCheDeployment(instance, cheImageRepo, cheImageTag, cmResourceVersion, isOpenShift)
cheDeployment, err := deploy.NewCheDeployment(instance, cheImageAndTag, cmResourceVersion, isOpenShift)
if err != nil {
logrus.Errorf("An error occurred: %s", err)
}
......@@ -1154,7 +1157,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
logrus.Errorf("Wrong quantity for Che deployment Memory Limit: %s", err)
return reconcile.Result{}, err
}
desiredImagePullPolicy := util.GetValue(string(instance.Spec.Server.CheImagePullPolicy), deploy.DefaultPullPolicyFromDockerImage(cheImageRepo+":"+cheImageTag))
desiredImagePullPolicy := util.GetValue(string(instance.Spec.Server.CheImagePullPolicy), deploy.DefaultPullPolicyFromDockerImage(cheImageAndTag))
effectiveImagePullPolicy := string(effectiveCheDeployment.Spec.Template.Spec.Containers[0].ImagePullPolicy)
desiredSelfSignedCert := instance.Spec.Server.SelfSignedCert
desiredGitSelfSignedCert := instance.Spec.Server.GitSelfSignedCert
......@@ -1165,7 +1168,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e
effectiveImagePullPolicy != desiredImagePullPolicy ||
effectiveSelfSignedCert != desiredSelfSignedCert ||
effectiveGitSelfSignedCert != desiredGitSelfSignedCert {
cheDeployment, err := deploy.NewCheDeployment(instance, cheImageRepo, cheImageTag, cmResourceVersion, isOpenShift)
cheDeployment, err := deploy.NewCheDeployment(instance, cheImageAndTag, cmResourceVersion, isOpenShift)
if err != nil {
logrus.Errorf("An error occurred: %s", err)
}
......@@ -1254,3 +1257,31 @@ func hasConsolelinkObject() bool {
}
return false
}
// GetFullCheServerImageLink evaluate full cheImage link(with repo and tag)
// based on Checluster information and image defaults from env variables
func GetFullCheServerImageLink(cr *orgv1.CheCluster) string {
if len(cr.Spec.Server.CheImage) > 0 {
cheServerImageTag := util.GetValue(cr.Spec.Server.CheImageTag, deploy.DefaultCheVersion())
return cr.Spec.Server.CheImage + ":" + cheServerImageTag
}
defaultCheServerImage := deploy.DefaultCheServerImage(cr)
if len(cr.Spec.Server.CheImageTag) == 0 {
return defaultCheServerImage
}
// For back compatibility with version < 7.9.0:
// if cr.Spec.Server.CheImage is empty, but cr.Spec.Server.CheImageTag is not empty,
// parse from default Che image(value comes from env variable) "Che image repository"
// and return "Che image", like concatenation: "cheImageRepo:cheImageTag"
separator := map[bool]string{true: "@", false: ":"}[strings.Contains(defaultCheServerImage, "@")]
imageParts := strings.Split(defaultCheServerImage, separator)
return imageParts[0] + ":" + cr.Spec.Server.CheImageTag
}
// EvaluateCheServerVersion evaluate che version
// based on Checluster information and image defaults from env variables
func EvaluateCheServerVersion(cr *orgv1.CheCluster) string {
return util.GetValue(cr.Spec.Server.CheImageTag, deploy.DefaultCheVersion())
}
......@@ -134,7 +134,7 @@ func GetConfigMapData(cr *orgv1.CheCluster) (cheEnv map[string]string) {
pvcClaimSize := util.GetValue(cr.Spec.Storage.PvcClaimSize, DefaultPvcClaimSize)
workspacePvcStorageClassName := cr.Spec.Storage.WorkspacePVCStorageClassName
defaultPVCJobsImage := DefaultPvcJobsImage(cr, cheFlavor)
defaultPVCJobsImage := DefaultPvcJobsImage(cr)
pvcJobsImage := util.GetValue(cr.Spec.Storage.PvcJobsImage, defaultPVCJobsImage)
preCreateSubPaths := "true"
if !cr.Spec.Storage.PreCreateSubPaths {
......@@ -191,9 +191,9 @@ func GetConfigMapData(cr *orgv1.CheCluster) (cheEnv map[string]string) {
WorkspaceNoProxy: cheWorkspaceNoProxy,
PluginRegistryUrl: pluginRegistryUrl,
DevfileRegistryUrl: devfileRegistryUrl,
CheWorkspacePluginBrokerMetadataImage: DefaultCheWorkspacePluginBrokerMetadataImage(cr, cheFlavor),
CheWorkspacePluginBrokerArtifactsImage: DefaultCheWorkspacePluginBrokerArtifactsImage(cr, cheFlavor),
CheServerSecureExposerJwtProxyImage: DefaultCheServerSecureExposerJwtProxyImage(cr, cheFlavor),
CheWorkspacePluginBrokerMetadataImage: DefaultCheWorkspacePluginBrokerMetadataImage(cr),
CheWorkspacePluginBrokerArtifactsImage: DefaultCheWorkspacePluginBrokerArtifactsImage(cr),
CheServerSecureExposerJwtProxyImage: DefaultCheServerSecureExposerJwtProxyImage(cr),
CheJGroupsKubernetesLabels: cheLabels,
CheMetricsEnabled: cheMetrics,
}
......
......@@ -14,31 +14,41 @@ package deploy
import (
"fmt"
"github.com/sirupsen/logrus"
"os"
"strings"
orgv1 "github.com/eclipse/che-operator/pkg/apis/org/v1"
)
var (
defaultCheServerImage string
defaultCheVersion string
defaultPluginRegistryImage string
defaultDevfileRegistryImage string
defaultPvcJobsImage string
defaultPostgresImage string
defaultKeycloakImage string
defaultCheWorkspacePluginBrokerMetadataImage string
defaultCheWorkspacePluginBrokerArtifactsImage string
defaultCheServerSecureExposerJwtProxyImage string
)
const (
defaultCheServerImageRepo = "quay.io/eclipse/che-server"
defaultCodeReadyServerImageRepo = "registry.redhat.io/codeready-workspaces/server-rhel8"
defaultCheServerImageTag = "7.8.0"
defaultCodeReadyServerImageTag = "2.1"
DefaultCheFlavor = "che"
DefaultChePostgresUser = "pgche"
DefaultChePostgresHostName = "postgres"
DefaultChePostgresPort = "5432"
DefaultChePostgresDb = "dbche"
DefaultPvcStrategy = "common"
DefaultPvcClaimSize = "1Gi"
DefaultIngressStrategy = "multi-host"
DefaultIngressClass = "nginx"
defaultPluginRegistryImage = "registry.redhat.io/codeready-workspaces/pluginregistry-rhel8:2.1"
defaultPluginRegistryUpstreamImage = "quay.io/eclipse/che-plugin-registry:7.8.0"
DefaultPluginRegistryMemoryLimit = "256Mi"
DefaultPluginRegistryMemoryRequest = "16Mi"
defaultDevfileRegistryImage = "registry.redhat.io/codeready-workspaces/devfileregistry-rhel8:2.1"
defaultDevfileRegistryUpstreamImage = "quay.io/eclipse/che-devfile-registry:7.8.0"
DefaultCheFlavor = "che"
DefaultChePostgresUser = "pgche"
DefaultChePostgresHostName = "postgres"
DefaultChePostgresPort = "5432"
DefaultChePostgresDb = "dbche"
DefaultPvcStrategy = "common"
DefaultPvcClaimSize = "1Gi"
DefaultIngressStrategy = "multi-host"
DefaultIngressClass = "nginx"
DefaultPluginRegistryMemoryLimit = "256Mi"
DefaultPluginRegistryMemoryRequest = "16Mi"
DefaultDevfileRegistryMemoryLimit = "256Mi"
DefaultDevfileRegistryMemoryRequest = "16Mi"
DefaultKeycloakAdminUserName = "admin"
......@@ -46,13 +56,8 @@ const (
DefaultCheDebug = "false"
DefaultCheMetricsPort = int32(8087)
DefaultCheDebugPort = int32(8000)
defaultPvcJobsImage = "registry.redhat.io/ubi8-minimal:8.0-213"
defaultPvcJobsUpstreamImage = "registry.access.redhat.com/ubi8-minimal:8.0-213"
defaultPostgresImage = "registry.redhat.io/rhscl/postgresql-96-rhel7:1-47"
defaultPostgresUpstreamImage = "centos/postgresql-96-centos7:9.6"
defaultKeycloakImage = "registry.redhat.io/redhat-sso-7/sso73-openshift:1.0-15"
defaultKeycloakUpstreamImage = "quay.io/eclipse/che-keycloak:7.8.0"
DefaultJavaOpts = "-XX:MaxRAMFraction=2 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10 " +
DefaultJavaOpts = "-XX:MaxRAMFraction=2 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10 " +
"-XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 " +
"-XX:AdaptiveSizePolicyWeight=90 -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap " +
"-Dsun.zip.disableMemoryMapping=true -Xms20m"
......@@ -65,15 +70,6 @@ const (
DefaultSecurityContextFsGroup = "1724"
DefaultSecurityContextRunAsUser = "1724"
// CRW images for that are mentioned in the Che server che.properties
// For CRW these should be synced by hand with images stored in RH registries
// instead of being synced by script with the content of the upstream `che.properties` file
// NB:
// The upstream equivalent are stored in the generated `extra_images.go` source file.
defaultCheWorkspacePluginBrokerMetadataImage = "quay.io/crw/pluginbroker-metadata-rhel8:2.1"
defaultCheWorkspacePluginBrokerArtifactsImage = "quay.io/crw/pluginbroker-artifacts-rhel8:2.1"
defaultCheServerSecureExposerJwtProxyImage = "quay.io/crw/jwtproxy-rhel8:2.1"
// This is only to correctly manage defaults during the transition
// from Upstream 7.0.0 GA to the next version
// That fixed bug https://github.com/eclipse/che/issues/13714
......@@ -93,10 +89,37 @@ const (
defaultConsoleLinkDisplayName = "CodeReady Workspaces"
)
func InitDefaultsFromEnv() {
defaultCheVersion = getDefaultFromEnv("CHE_VERSION")
defaultCheServerImage = getDefaultFromEnv("IMAGE_default_che_server")
defaultPluginRegistryImage = getDefaultFromEnv("IMAGE_default_plugin_registry")
defaultDevfileRegistryImage = getDefaultFromEnv("IMAGE_default_devfile_registry")
defaultPvcJobsImage = getDefaultFromEnv("IMAGE_default_pvc_jobs")
defaultPostgresImage = getDefaultFromEnv("IMAGE_default_postgres")
defaultKeycloakImage = getDefaultFromEnv("IMAGE_default_keycloak")
// CRW images for that are mentioned in the Che server che.properties
// For CRW these should be synced by hand with images stored in RH registries
// instead of being synced by script with the content of the upstream `che.properties` file
defaultCheWorkspacePluginBrokerMetadataImage = getDefaultFromEnv("IMAGE_default_che_workspace_plugin_broker_metadata")
defaultCheWorkspacePluginBrokerArtifactsImage = getDefaultFromEnv("IMAGE_default_che_workspace_plugin_broker_artifacts")
defaultCheServerSecureExposerJwtProxyImage = getDefaultFromEnv("IMAGE_default_che_server_secure_exposer_jwt_proxy_image")
}
func getDefaultFromEnv(envName string) string {
value := os.Getenv(envName)
if len(value) == 0 {
logrus.Fatalf("Failed to initialize default value: '%s'. Environment variable with default value was not found.", envName)
}
return value
}
func MigratingToCRW2_0(cr *orgv1.CheCluster) bool {
if cr.Spec.Server.CheFlavor == "codeready" &&
strings.HasPrefix(cr.Status.CheVersion, "1.2") &&
strings.HasPrefix(defaultCodeReadyServerImageTag, "2.0") {
strings.HasPrefix(defaultCheVersion, "2.0") {
return true
}