diff --git a/.github/bin/check-resources.sh b/.github/bin/check-resources.sh index c0827be38..d2e95cf6c 100755 --- a/.github/bin/check-resources.sh +++ b/.github/bin/check-resources.sh @@ -117,14 +117,11 @@ checkOperatorYaml() { checkDW() { # files to check - local CHEMANAGER_CRD="deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml" - local DWROUTINGS_CRD="deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml" - local CWCO_CONFIGMAP="deploy/dev-workspace/devworkspace-che-configmap.ConfigMap.yaml" - local DWCO_SERVICE="deploy/dev-workspace/devworkspace-che-controller-manager-metrics-service.Service.yaml" + local CHEMANAGER_CRD="deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml" + local DWROUTINGS_CRD="deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml" changedFiles=($(git diff --name-only)) - if [[ " ${changedFiles[*]} " =~ $CHEMANAGER_CRD ]] || [[ " ${changedFiles[*]} " =~ $CWCO_CONFIGMAP ]] || \ - [[ " ${changedFiles[*]} " =~ $DWCO_SERVICE ]] || [[ " ${changedFiles[*]} " =~ $DWROUTINGS_CRD ]]; then + if [[ " ${changedFiles[*]} " =~ $CHEMANAGER_CRD ]] || [[ " ${changedFiles[*]} " =~ $DWROUTINGS_CRD ]]; then echo "[ERROR] DWCO resources are not up to date: ${BASH_REMATCH}" echo "[ERROR] Run 'olm/update-resources.sh' to download them." exit 1 diff --git a/deploy.sh b/deploy.sh index a30678541..91ebb49b6 100755 --- a/deploy.sh +++ b/deploy.sh @@ -21,16 +21,12 @@ while [[ "$#" -gt 0 ]]; do case $1 in '--namespace'|'-n') NAMESPACE=$2; shift 1;; '--che-operator-image') CHE_OPERATOR_IMAGE=$2; shift 1;; - '--logs') LOGS=true; + '--logs') LOGS=true;; esac shift 1 done -echo "[INFO] Deploying Eclipse Che in namespace: "$NAMESPACE -set +e; oc create namespace $ECLIPSE_CHE_NAMESPACE; set -e - -echo "[INFO] Creating SA roles and clusterroles" - +set +e; oc create namespace $NAMESPACE; set -e oc apply -f ${BASE_DIR}/deploy/service_account.yaml -n $NAMESPACE oc apply -f ${BASE_DIR}/deploy/role.yaml -n $NAMESPACE oc apply -f ${BASE_DIR}/deploy/role_binding.yaml -n $NAMESPACE @@ -38,26 +34,18 @@ oc apply -f ${BASE_DIR}/deploy/cluster_role.yaml -n $NAMESPACE oc apply -f ${BASE_DIR}/deploy/cluster_role_binding.yaml -n $NAMESPACE oc apply -f ${BASE_DIR}/deploy/proxy_cluster_role.yaml -n $NAMESPACE oc apply -f ${BASE_DIR}/deploy/proxy_cluster_role_binding.yaml -n $NAMESPACE - -echo "[INFO] Creating Custom Resource Difinition" - oc apply -f ${BASE_DIR}/deploy/crds/org_v1_che_crd.yaml -n $NAMESPACE -oc apply -f ${BASE_DIR}/deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml -n $NAMESPACE -oc apply -f ${BASE_DIR}/deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml -n $NAMESPACE +oc apply -f ${BASE_DIR}/deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml -n $NAMESPACE +oc apply -f ${BASE_DIR}/deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml -n $NAMESPACE sleep 5 -echo "[INFO] Creating operator deployment, image: "$CHE_OPERATOR_IMAGE - cp -f ${BASE_DIR}/deploy/operator.yaml /tmp/operator.yaml yq -riyY "( .spec.template.spec.containers[] | select(.name == \"che-operator\") | .image ) = \"${CHE_OPERATOR_IMAGE}\"" /tmp/operator.yaml - oc apply -f /tmp/operator.yaml -n $NAMESPACE - -echo "[INFO] Creating Custom Resource" - oc apply -f ${BASE_DIR}/deploy/crds/org_v1_che_cr.yaml -n $NAMESPACE if [[ $LOGS == true ]]; then - echo "[INFO] Start printing logs" - oc logs $(oc get pods -o json -n $NAMESPACE | jq -r '.items[] | select(.metadata.name | test("che-operator-")).metadata.name') -n $NAMESPACE --all-containers + echo "[INFO] Start printing logs..." + oc wait --for=condition=ready pod -l app.kubernetes.io/component=che-operator -n $NAMESPACE --timeout=60s + oc logs $(oc get pods -o json -n $NAMESPACE | jq -r '.items[] | select(.metadata.name | test("che-operator-")).metadata.name') -n $NAMESPACE --all-containers -f fi diff --git a/deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml b/deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml similarity index 100% rename from deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml rename to deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml diff --git a/deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml b/deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml similarity index 100% rename from deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml rename to deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml diff --git a/deploy/dev-workspace/devworkspace-che-configmap.ConfigMap.yaml b/deploy/dev-workspace/devworkspace-che-configmap.ConfigMap.yaml deleted file mode 100644 index aca30f7cf..000000000 --- a/deploy/dev-workspace/devworkspace-che-configmap.ConfigMap.yaml +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - labels: - app.kubernetes.io/name: devworkspace-che-operator - app.kubernetes.io/part-of: devworkspace-che-operator - name: devworkspace-che-configmap - namespace: devworkspace-che diff --git a/deploy/dev-workspace/devworkspace-che-controller-manager-metrics-service.Service.yaml b/deploy/dev-workspace/devworkspace-che-controller-manager-metrics-service.Service.yaml deleted file mode 100644 index 55f1ae3a7..000000000 --- a/deploy/dev-workspace/devworkspace-che-controller-manager-metrics-service.Service.yaml +++ /dev/null @@ -1,18 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - labels: - app.kubernetes.io/name: devworkspace-che-operator - app.kubernetes.io/part-of: devworkspace-che-operator - control-plane: controller-manager - name: devworkspace-che-controller-manager-metrics-service - namespace: devworkspace-che -spec: - ports: - - name: https - port: 8443 - targetPort: https - selector: - app.kubernetes.io/name: devworkspace-che-operator - app.kubernetes.io/part-of: devworkspace-che-operator - control-plane: controller-manager diff --git a/deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/csv-config.yaml b/deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/csv-config.yaml index f72fdf69e..488bfc6eb 100644 --- a/deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/csv-config.yaml +++ b/deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/csv-config.yaml @@ -1,3 +1,3 @@ role-paths: [ "deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/generated/roles/role.yaml", "deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/generated/roles/cluster_role.yaml", "deploy/olm-catalog/nightly/eclipse-che-preview-kubernetes/generated/roles/proxy_cluster_role.yaml"] operator-path: deploy/operator.yaml -crd-cr-paths: ["deploy/crds/org_v1_che_crd.yaml", "deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml", deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml"] +crd-cr-paths: ["deploy/crds/org_v1_che_crd.yaml", "deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml", deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml"] diff --git a/deploy/olm-catalog/nightly/eclipse-che-preview-openshift/csv-config.yaml b/deploy/olm-catalog/nightly/eclipse-che-preview-openshift/csv-config.yaml index 0fcaf746b..b22fba54e 100644 --- a/deploy/olm-catalog/nightly/eclipse-che-preview-openshift/csv-config.yaml +++ b/deploy/olm-catalog/nightly/eclipse-che-preview-openshift/csv-config.yaml @@ -1,3 +1,3 @@ operator-path: deploy/operator.yaml role-paths: [ "deploy/olm-catalog/nightly/eclipse-che-preview-openshift/generated/roles/role.yaml", "deploy/olm-catalog/nightly/eclipse-che-preview-openshift/generated/roles/cluster_role.yaml", "deploy/olm-catalog/nightly/eclipse-che-preview-openshift/generated/roles/proxy_cluster_role.yaml"] -crd-cr-paths: ["deploy/crds/org_v1_che_crd.yaml", "deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml", "deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml"] +crd-cr-paths: ["deploy/crds/org_v1_che_crd.yaml", "deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml", "deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml"] diff --git a/deploy/operator.yaml b/deploy/operator.yaml index 095698488..ed5bd9f03 100644 --- a/deploy/operator.yaml +++ b/deploy/operator.yaml @@ -30,7 +30,6 @@ spec: app.kubernetes.io/name: che app.kubernetes.io/instance: che app.kubernetes.io/component: che-operator - control-plane: controller-manager spec: containers: - name: che-operator diff --git a/local-debug.sh b/local-debug.sh index 67203ccf2..a5f3b2a5e 100755 --- a/local-debug.sh +++ b/local-debug.sh @@ -18,8 +18,8 @@ command -v operator-sdk >/dev/null 2>&1 || { echo "operator-sdk is not installed ECLIPSE_CHE_NAMESPACE="eclipse-che" ECLIPSE_CHE_CR="./deploy/crds/org_v1_che_cr.yaml" ECLIPSE_CHE_CRD="./deploy/crds/org_v1_che_crd.yaml" -ECLIPSE_CHE_MANAGER_CRD="./deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml" -ECLIPSE_CHE_DWROUTING_CRD="./deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml" +ECLIPSE_CHE_MANAGER_CRD="./deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml" +ECLIPSE_CHE_DWROUTING_CRD="./deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml" DEV_WORKSPACE_CONTROLLER_VERSION="main" DEV_WORKSPACE_CHE_OPERATOR_VERSION="main" @@ -69,11 +69,6 @@ prepareTemplates() { cp -rf /tmp/devfile-devworkspace-operator*/deploy/* /tmp/devworkspace-operator/templates echo "[INFO] Downloading Dev Workspace operator templates completed." - - # Copy Dev Workspace Che operator templates - rm -rf /tmp/devworkspace-che-operator/ - mkdir -p /tmp/devworkspace-che-operator/templates - cp -rf deploy/dev-workspace/* /tmp/devworkspace-che-operator/templates } createNamespace() { diff --git a/olm/update-resources.sh b/olm/update-resources.sh index f6720033b..fd4d03ad6 100755 --- a/olm/update-resources.sh +++ b/olm/update-resources.sh @@ -144,8 +144,8 @@ updateNighltyBundle() { # copy CR/CRD cp -f "${ROOT_PROJECT_DIR}/deploy/crds/org_v1_che_cr.yaml" "${generateFolder}/crds" cp -f "${ROOT_PROJECT_DIR}/deploy/crds/org_v1_che_crd.yaml" "${generateFolder}/crds" - cp -f "${ROOT_PROJECT_DIR}/deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml" "${generateFolder}/crds" - cp -f "${ROOT_PROJECT_DIR}/deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml" "${generateFolder}/crds" + cp -f "${ROOT_PROJECT_DIR}/deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml" "${generateFolder}/crds" + cp -f "${ROOT_PROJECT_DIR}/deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml" "${generateFolder}/crds" # generate a new CSV "${OPERATOR_SDK_BINARY}" generate csv \ @@ -172,8 +172,8 @@ updateNighltyBundle() { cp -f "${ROOT_PROJECT_DIR}/deploy/crds/org_v1_che_crd.yaml" "${NIGHTLY_BUNDLE_PATH}/manifests" - cp -f "${ROOT_PROJECT_DIR}/deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml" "${NIGHTLY_BUNDLE_PATH}/manifests" - cp -f "${ROOT_PROJECT_DIR}/deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml" "${NIGHTLY_BUNDLE_PATH}/manifests" + cp -f "${ROOT_PROJECT_DIR}/deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml" "${NIGHTLY_BUNDLE_PATH}/manifests" + cp -f "${ROOT_PROJECT_DIR}/deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml" "${NIGHTLY_BUNDLE_PATH}/manifests" CRD="${NIGHTLY_BUNDLE_PATH}/manifests/org_v1_che_crd.yaml" if [[ $platform == "openshift" ]]; then @@ -243,13 +243,9 @@ updateNighltyBundle() { updateDW() { echo "[INFO] Downloading DevWorkspace resources" curl -sL https://raw.githubusercontent.com/che-incubator/devworkspace-che-operator/main/deploy/deployment/openshift/objects/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml \ - -o ${ROOT_PROJECT_DIR}/deploy/dev-workspace/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml - curl -sL https://raw.githubusercontent.com/che-incubator/devworkspace-che-operator/main/deploy/deployment/openshift/objects/devworkspace-che-configmap.ConfigMap.yaml \ - -o ${ROOT_PROJECT_DIR}/deploy/dev-workspace/devworkspace-che-configmap.ConfigMap.yaml - curl -sL https://raw.githubusercontent.com/che-incubator/devworkspace-che-operator/main/deploy/deployment/openshift/objects/devworkspace-che-controller-manager-metrics-service.Service.yaml \ - -o ${ROOT_PROJECT_DIR}/deploy/dev-workspace/devworkspace-che-controller-manager-metrics-service.Service.yaml + -o ${ROOT_PROJECT_DIR}/deploy/crds/chemanagers.che.eclipse.org.CustomResourceDefinition.yaml curl -sL https://raw.githubusercontent.com/devfile/devworkspace-operator/main/deploy/deployment/openshift/objects/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml \ - -o ${ROOT_PROJECT_DIR}/deploy/dev-workspace/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml + -o ${ROOT_PROJECT_DIR}/deploy/crds/devworkspaceroutings.controller.devfile.io.CustomResourceDefinition.yaml } addLicenseHeader() { diff --git a/pkg/deploy/dev-workspace/dev_workspace.go b/pkg/deploy/dev-workspace/dev_workspace.go index 039b4fcd9..76d13623b 100644 --- a/pkg/deploy/dev-workspace/dev_workspace.go +++ b/pkg/deploy/dev-workspace/dev_workspace.go @@ -68,9 +68,6 @@ var ( DevWorkspaceConfigMapFile = DevWorkspaceTemplates + "/devworkspace-controller-configmap.ConfigMap.yaml" DevWorkspaceDeploymentFile = DevWorkspaceTemplates + "/devworkspace-controller-manager.Deployment.yaml" - DevWorkspaceCheConfigMapFile = DevWorkspaceCheTemplates + "/devworkspace-che-configmap.ConfigMap.yaml" - DevWorkspaceCheMetricsServiceFile = DevWorkspaceCheTemplates + "/devworkspace-che-controller-manager-metrics-service.Service.yaml" - WebTerminalOperatorSubscriptionName = "web-terminal" WebTerminalOperatorNamespace = "openshift-operators" ) @@ -103,7 +100,6 @@ var ( syncDwCheItems = []func(*deploy.DeployContext) (bool, error){ synDwCheCR, - syncDwCheConfigMap, syncDwCheMetricsService, } ) @@ -303,6 +299,14 @@ func synDwCheCR(deployContext *deploy.DeployContext) (bool, error) { if obj == nil { obj := &unstructured.Unstructured{} + if !util.IsOpenShift { + obj.SetUnstructuredContent(map[string]interface{}{ + "spec": map[string]interface{}{ + "gatewayHost": deployContext.CheCluster.Spec.K8s.IngressDomain, + "k8s": map[string]interface{}{}, + }, + }) + } obj.SetGroupVersionKind(schema.GroupVersionKind{ Group: "che.eclipse.org", Version: "v1alpha1", diff --git a/pkg/deploy/service.go b/pkg/deploy/service.go index a4bf46b57..5bd8f7550 100644 --- a/pkg/deploy/service.go +++ b/pkg/deploy/service.go @@ -25,7 +25,7 @@ const ( CheServiceName = "che-host" ) -var ServiceDefaultDiffOpts = cmp.Options{ +var DefaultServiceDiffOpts = cmp.Options{ cmpopts.IgnoreFields(corev1.Service{}, "TypeMeta", "ObjectMeta"), cmp.Comparer(func(x, y corev1.ServiceSpec) bool { return cmp.Equal(x.Ports, y.Ports, cmpopts.IgnoreFields(corev1.ServicePort{}, "TargetPort", "NodePort")) && @@ -45,7 +45,7 @@ func SyncServiceToCluster( } func SyncServiceSpecToCluster(deployContext *DeployContext, serviceSpec *corev1.Service) (bool, error) { - return Sync(deployContext, serviceSpec, ServiceDefaultDiffOpts) + return Sync(deployContext, serviceSpec, DefaultServiceDiffOpts) } func GetServiceSpec( diff --git a/pkg/deploy/sync.go b/pkg/deploy/sync.go index beb28d670..dc0586529 100644 --- a/pkg/deploy/sync.go +++ b/pkg/deploy/sync.go @@ -142,11 +142,7 @@ func CreateIfNotExists(deployContext *DeployContext, blueprint metav1.Object) (b return false, err } - if blueprint.GetNamespace() == "" { - logrus.Infof("Creating a new object: %s, name: %s", getObjectType(blueprint), blueprint.GetName()) - } else { - logrus.Infof("Creating a new object: %s, name: %s, namespace: %s", getObjectType(blueprint), blueprint.GetName(), blueprint.GetNamespace()) - } + logrus.Infof("Creating a new object: %s, name: %s", getObjectType(blueprint), blueprint.GetName()) err = setOwnerReferenceIfNeeded(deployContext, blueprint) if err != nil {