From 73053b2bc4ff4db49230e306890ce18f4792f20d Mon Sep 17 00:00:00 2001 From: Oleksandr Andriienko Date: Thu, 26 Nov 2020 13:54:26 +0200 Subject: [PATCH] Provide internal network urls for plugin registry, devfile registry and internal che api endpoint url. (#468) * Provide internal network urls for plugin, devfile registries and internal che api endpoint url. Signed-off-by: Oleksandr Andriienko --- .ci/cico_minishift_nightly.sh | 1 + .ci/cico_updates_minishift.sh | 1 + .vscode/launch.json | 8 +- .vscode/tasks.json | 36 ++++ deploy/crds/org_v1_che_cr.yaml | 2 + deploy/crds/org_v1_che_crd.yaml | 5 + .../che-operator.clusterserviceversion.yaml | 7 +- .../manifests/org_v1_che_crd.yaml | 5 + .../che-operator.clusterserviceversion.yaml | 7 +- .../manifests/org_v1_che_crd.yaml | 5 + e2e/create.go | 4 +- olm/README.md | 2 +- pkg/apis/org/v1/che_types.go | 6 + pkg/controller/che/che_controller.go | 25 +-- pkg/controller/che/che_controller_test.go | 167 +++++++++++++++++- pkg/deploy/data_types.go | 13 +- pkg/deploy/defaults.go | 1 + .../devfile-registry/devfile_registry.go | 2 + pkg/deploy/expose/expose.go | 19 +- pkg/deploy/plugin-registry/plugin_registry.go | 2 + pkg/deploy/server/che_configmap.go | 30 +++- 21 files changed, 302 insertions(+), 46 deletions(-) diff --git a/.ci/cico_minishift_nightly.sh b/.ci/cico_minishift_nightly.sh index 5f17ffafc..5eb871f01 100755 --- a/.ci/cico_minishift_nightly.sh +++ b/.ci/cico_minishift_nightly.sh @@ -80,6 +80,7 @@ function run() { # OPERATOR_IMAGE In CI is defined in .github/workflows/che-nightly.yaml export OPERATOR_IMAGE="quay.io/eclipse/che-operator:test" + rm -rf tmp # prepare template folder mkdir -p "${OPERATOR_REPO}/tmp/che-operator" && chmod 777 "${OPERATOR_REPO}/tmp" cp -rf ${OPERATOR_REPO}/deploy/* "${OPERATOR_REPO}/tmp/che-operator" diff --git a/.ci/cico_updates_minishift.sh b/.ci/cico_updates_minishift.sh index 3aa06f0d6..3e7142ade 100755 --- a/.ci/cico_updates_minishift.sh +++ b/.ci/cico_updates_minishift.sh @@ -62,6 +62,7 @@ function init() { export lastOperatorTemplate=${lastOperatorPath}/chectl/templates export previousOperatorTemplate=${previousOperatorPath}/chectl/templates + rm -rf tmp # Create tmp folder to save "operator" installer templates mkdir -p "${OPERATOR_REPO}/tmp" && chmod 777 "${OPERATOR_REPO}/tmp" diff --git a/.vscode/launch.json b/.vscode/launch.json index ec5dc1e47..e14fdd8a3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -139,7 +139,7 @@ "program": "${file}" }, { - "name": "Launch Current File", + "name": "Launch Current Test *.go File", "type": "go", "request": "launch", "mode": "test", @@ -148,6 +148,12 @@ "MOCK_API": true }, }, + { + "name": "Launch Main *.go File", + "type": "go", + "request": "launch", + "program": "${file}", + }, { "useApiV1": false, "dlvLoadConfig": { diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 06eccb8ab..477cf2672 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,6 +1,42 @@ { "version": "2.0.0", "tasks": [ + { + "label": "Update vendor folder", + "command": "go mod vendor", + "options": { + "env": { + "MOCK_API": "true" + } + }, + "type": "shell", + "args": [], + "problemMatcher": [ + "$go" + ], + "presentation": { + "reveal": "always" + }, + "group": "build" + }, + { + "label": "Run mock tests", + "command": "go test -mod=vendor -v ./...", + "options": { + "env": { + "MOCK_API": "true" + } + }, + "type": "shell", + "args": [], + "problemMatcher": [ + "$go" + ], + "presentation": { + "reveal": "always" + }, + "group": "build" + }, { "label": "Update cr/crd files", "command": "./olm/update-crd-files.sh", diff --git a/deploy/crds/org_v1_che_cr.yaml b/deploy/crds/org_v1_che_cr.yaml index db72ec63f..6786db8b8 100644 --- a/deploy/crds/org_v1_che_cr.yaml +++ b/deploy/crds/org_v1_che_cr.yaml @@ -16,6 +16,8 @@ metadata: name: eclipse-che spec: server: + # use internal host names provided by cluster dns. + useInternalClusterSVCNames: true # server image used in Che deployment cheImage: '' # tag of an image used in Che deployment diff --git a/deploy/crds/org_v1_che_crd.yaml b/deploy/crds/org_v1_che_crd.yaml index a3cee19ff..0fc752d8d 100644 --- a/deploy/crds/org_v1_che_crd.yaml +++ b/deploy/crds/org_v1_che_crd.yaml @@ -576,6 +576,11 @@ spec: TLS mode. This is enabled by default. Disabling TLS may cause malfunction of some Che components. type: boolean + useInternalClusterSVCNames: + description: Use internal cluster svc names to communicate between + components to speed up the traffic and avoid proxy issues. The + default value is `true`. + type: boolean workspaceNamespaceDefault: description: 'Defines Kubernetes default namespace in which user''s workspaces are created if user does not override it. It''s possible diff --git a/deploy/olm-catalog/eclipse-che-preview-kubernetes/manifests/che-operator.clusterserviceversion.yaml b/deploy/olm-catalog/eclipse-che-preview-kubernetes/manifests/che-operator.clusterserviceversion.yaml index ea4b353b7..f6d0e281e 100644 --- a/deploy/olm-catalog/eclipse-che-preview-kubernetes/manifests/che-operator.clusterserviceversion.yaml +++ b/deploy/olm-catalog/eclipse-che-preview-kubernetes/manifests/che-operator.clusterserviceversion.yaml @@ -65,6 +65,7 @@ metadata: "singleHostGatewayConfigSidecarImage": "", "singleHostGatewayImage": "", "tlsSupport": true, + "useInternalClusterSVCNames": true, "workspaceNamespaceDefault": "" }, "storage": { @@ -82,13 +83,13 @@ metadata: categories: Developer Tools certified: "false" containerImage: quay.io/eclipse/che-operator:nightly - createdAt: "2020-11-17T10:26:58Z" + createdAt: "2020-11-25T12:37:35Z" description: A Kube-native development solution that delivers portable and collaborative developer workspaces. operatorframework.io/suggested-namespace: eclipse-che repository: https://github.com/eclipse/che-operator support: Eclipse Foundation - name: eclipse-che-preview-kubernetes.v7.22.0-33.nightly + name: eclipse-che-preview-kubernetes.v7.23.0-36.nightly namespace: placeholder spec: apiservicedefinitions: {} @@ -470,4 +471,4 @@ spec: maturity: stable provider: name: Eclipse Foundation - version: 7.22.0-33.nightly + version: 7.23.0-36.nightly diff --git a/deploy/olm-catalog/eclipse-che-preview-kubernetes/manifests/org_v1_che_crd.yaml b/deploy/olm-catalog/eclipse-che-preview-kubernetes/manifests/org_v1_che_crd.yaml index a3cee19ff..0fc752d8d 100644 --- a/deploy/olm-catalog/eclipse-che-preview-kubernetes/manifests/org_v1_che_crd.yaml +++ b/deploy/olm-catalog/eclipse-che-preview-kubernetes/manifests/org_v1_che_crd.yaml @@ -576,6 +576,11 @@ spec: TLS mode. This is enabled by default. Disabling TLS may cause malfunction of some Che components. type: boolean + useInternalClusterSVCNames: + description: Use internal cluster svc names to communicate between + components to speed up the traffic and avoid proxy issues. The + default value is `true`. + type: boolean workspaceNamespaceDefault: description: 'Defines Kubernetes default namespace in which user''s workspaces are created if user does not override it. It''s possible diff --git a/deploy/olm-catalog/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml b/deploy/olm-catalog/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml index a9b1ce56f..8b16db26b 100644 --- a/deploy/olm-catalog/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml +++ b/deploy/olm-catalog/eclipse-che-preview-openshift/manifests/che-operator.clusterserviceversion.yaml @@ -57,6 +57,7 @@ metadata: "singleHostGatewayConfigSidecarImage": "", "singleHostGatewayImage": "", "tlsSupport": true, + "useInternalClusterSVCNames": true, "workspaceNamespaceDefault": "" }, "storage": { @@ -74,13 +75,13 @@ metadata: categories: Developer Tools, OpenShift Optional certified: "false" containerImage: quay.io/eclipse/che-operator:nightly - createdAt: "2020-11-17T10:27:06Z" + createdAt: "2020-11-25T12:37:42Z" description: A Kube-native development solution that delivers portable and collaborative developer workspaces in OpenShift. operatorframework.io/suggested-namespace: eclipse-che repository: https://github.com/eclipse/che-operator support: Eclipse Foundation - name: eclipse-che-preview-openshift.v7.22.0-33.nightly + name: eclipse-che-preview-openshift.v7.23.0-36.nightly namespace: placeholder spec: apiservicedefinitions: {} @@ -490,4 +491,4 @@ spec: maturity: stable provider: name: Eclipse Foundation - version: 7.22.0-33.nightly + version: 7.23.0-36.nightly diff --git a/deploy/olm-catalog/eclipse-che-preview-openshift/manifests/org_v1_che_crd.yaml b/deploy/olm-catalog/eclipse-che-preview-openshift/manifests/org_v1_che_crd.yaml index bafc1b4c8..b202b5db0 100644 --- a/deploy/olm-catalog/eclipse-che-preview-openshift/manifests/org_v1_che_crd.yaml +++ b/deploy/olm-catalog/eclipse-che-preview-openshift/manifests/org_v1_che_crd.yaml @@ -577,6 +577,11 @@ spec: TLS mode. This is enabled by default. Disabling TLS may cause malfunction of some Che components. type: boolean + useInternalClusterSVCNames: + description: Use internal cluster svc names to communicate between + components to speed up the traffic and avoid proxy issues. The + default value is `true`. + type: boolean workspaceNamespaceDefault: description: 'Defines Kubernetes default namespace in which user''s workspaces are created if user does not override it. It''s possible diff --git a/e2e/create.go b/e2e/create.go index 42599958f..64fa08d73 100644 --- a/e2e/create.go +++ b/e2e/create.go @@ -119,7 +119,9 @@ func newCheCluster() (cr *orgv1.CheCluster) { Kind: kind, }, Spec: orgv1.CheClusterSpec{ - Server: orgv1.CheClusterSpecServer{}, + Server: orgv1.CheClusterSpecServer{ + UseInternalClusterSVCNames: true, + }, }, } return cr diff --git a/olm/README.md b/olm/README.md index a58f5553d..a9f69a6cd 100644 --- a/olm/README.md +++ b/olm/README.md @@ -196,7 +196,7 @@ $ export IMAGE_REGISTRY_HOST="localhost:5000" && \ > Tips: If minikube was installed locally(driver 'none', local installation minikube), then registry is available on the host 0.0.0.0 without port forwarding. But local installation minikube required 'sudo'. -### 8. Test script arguments +### 8. Test scripts arguments There are some often used test script arguments: - `platform` - 'openshift' or 'kubernetes' - `channel` - installation Olm channel: 'nightly' or 'stable' diff --git a/pkg/apis/org/v1/che_types.go b/pkg/apis/org/v1/che_types.go index bf5ca4509..68b6b4a4d 100644 --- a/pkg/apis/org/v1/che_types.go +++ b/pkg/apis/org/v1/che_types.go @@ -141,6 +141,12 @@ type CheClusterSpecServer struct { // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.displayName="Tls support" // +operator-sdk:gen-csv:customresourcedefinitions.specDescriptors.x-descriptors="urn:alm:descriptor:com.tectonic.ui:booleanSwitch" TlsSupport bool `json:"tlsSupport"` + + // Use internal cluster svc names to communicate between components to speed up the traffic + // and avoid proxy issues. + // The default value is `true`. + UseInternalClusterSVCNames bool `json:"useInternalClusterSVCNames"` + // Public URL of the Devfile registry, that serves sample, ready-to-use devfiles. // You should set it ONLY if you use an external devfile registry (see the `externalDevfileRegistry` field). // By default this will be automatically calculated by the operator. diff --git a/pkg/controller/che/che_controller.go b/pkg/controller/che/che_controller.go index 4efc06a4b..054e30f23 100644 --- a/pkg/controller/che/che_controller.go +++ b/pkg/controller/che/che_controller.go @@ -294,6 +294,7 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e deployContext := &deploy.DeployContext{ ClusterAPI: clusterAPI, CheCluster: instance, + InternalService: deploy.InternalService{}, } isOpenShift, isOpenShift4, err := util.DetectOpenShift() @@ -754,6 +755,8 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e } } + deployContext.InternalService.CheHost = fmt.Sprintf("http://%s.%s.svc:8080", deploy.CheServiceName, deployContext.CheCluster.Namespace) + exposedServiceName := getServerExposingServiceName(instance) cheHost := "" if !isOpenShift { @@ -779,19 +782,17 @@ func (r *ReconcileChe) Reconcile(request reconcile.Request) (reconcile.Result, e additionalLabels := deployContext.CheCluster.Spec.Server.CheServerRoute.Labels route, err := deploy.SyncRouteToCluster(deployContext, cheFlavor, customHost, exposedServiceName, 8080, additionalLabels) - if !tests { - if route == nil { - logrus.Infof("Waiting on route '%s' to be ready", cheFlavor) - if err != nil { - logrus.Error(err) - } + if route == nil { + logrus.Infof("Waiting on route '%s' to be ready", cheFlavor) + if err != nil { + logrus.Error(err) + } - return reconcile.Result{RequeueAfter: time.Second * 1}, err - } - cheHost = route.Spec.Host - if customHost == "" { - deployContext.DefaultCheHost = cheHost - } + return reconcile.Result{RequeueAfter: time.Second * 1}, err + } + cheHost = route.Spec.Host + if customHost == "" { + deployContext.DefaultCheHost = cheHost } } if instance.Spec.Server.CheHost != cheHost { diff --git a/pkg/controller/che/che_controller_test.go b/pkg/controller/che/che_controller_test.go index 72badc314..76bcb5cd5 100644 --- a/pkg/controller/che/che_controller_test.go +++ b/pkg/controller/che/che_controller_test.go @@ -84,10 +84,23 @@ func TestCheController(t *testing.T) { Namespace: namespace, }, } + _, err := r.Reconcile(req) if err != nil { t.Fatalf("reconcile: (%v)", err) } + _, err = r.Reconcile(req) + if err != nil { + t.Fatalf("reconcile: (%v)", err) + } + _, err = r.Reconcile(req) + if err != nil { + t.Fatalf("reconcile: (%v)", err) + } + _, err = r.Reconcile(req) + if err != nil { + t.Fatalf("reconcile: (%v)", err) + } // get devfile-registry configmap devfilecm := &corev1.ConfigMap{} @@ -106,6 +119,14 @@ func TestCheController(t *testing.T) { if err != nil { t.Fatalf("reconcile: (%v)", err) } + _, err = r.Reconcile(req) + if err != nil { + t.Fatalf("reconcile: (%v)", err) + } + _, err = r.Reconcile(req) + if err != nil { + t.Fatalf("reconcile: (%v)", err) + } // get configmap cm := &corev1.ConfigMap{} @@ -115,12 +136,6 @@ func TestCheController(t *testing.T) { customCm := &corev1.ConfigMap{} - // Reconcile to delete legacy custom configmap - _, err = r.Reconcile(req) - if err != nil { - t.Fatalf("reconcile: (%v)", err) - } - // Custom ConfigMap should be gone err = cl.Get(context.TODO(), types.NamespacedName{Name: "custom", Namespace: cheCR.Namespace}, customCm) if !errors.IsNotFound(err) { @@ -150,6 +165,7 @@ func TestCheController(t *testing.T) { if err := cl.Update(context.TODO(), cheCR); err != nil { t.Error("Failed to update CheCluster custom resource") } + _, err = r.Reconcile(req) if err != nil { t.Fatalf("reconcile: (%v)", err) @@ -318,6 +334,145 @@ func TestConfiguringLabelsForRoutes(t *testing.T) { } } +func TestConfiguringInternalNetworkTest(t *testing.T) { + // Set the logger to development mode for verbose logs. + logf.SetLogger(logf.ZapLogger(true)) + + cl, scheme := Init() + + // Create a ReconcileChe object with the scheme and fake client + r := &ReconcileChe{client: cl, nonCachedClient: cl, scheme: &scheme, tests: true} + + // get CR + cheCR := &orgv1.CheCluster{} + + // get CR + if err := cl.Get(context.TODO(), types.NamespacedName{Name: name, Namespace: namespace}, cheCR); err != nil { + t.Errorf("CR not found") + } + cheCR.Spec.Server.UseInternalClusterSVCNames = true + if err := cl.Update(context.TODO(), cheCR); err != nil { + t.Errorf("Failed to update CheCluster custom resource") + } + + // Mock request to simulate Reconcile() being called on an event for a + // watched resource . + req := reconcile.Request{ + NamespacedName: types.NamespacedName{ + Name: name, + Namespace: namespace, + }, + } + // reconcile to delete che route + _, err := r.Reconcile(req) + if err != nil { + t.Fatalf("reconcile: (%v)", err) + } + + // reconcile to create che-route + _, err = r.Reconcile(req) + if err != nil { + t.Fatalf("reconcile: (%v)", err) + } + + clusterAPI := deploy.ClusterAPI{ + Client: r.client, + Scheme: r.scheme, + } + deployContext := &deploy.DeployContext{ + CheCluster: cheCR, + ClusterAPI: clusterAPI, + } + + // Set up che host for route + cheRoute, _ := deploy.GetSpecRoute(deployContext, "che", "che-host", "che-host", 8080, "") + cl.Update(context.TODO(), cheRoute) + + // reconsile to update Che route + _, err = r.Reconcile(req) + if err != nil { + t.Fatalf("reconcile: (%v)", err) + } + + // Set up keycloak host for route + keycloakRoute, _ := deploy.GetSpecRoute(deployContext, "keycloak", "keycloak", "keycloak", 8080, "") + cl.Update(context.TODO(), keycloakRoute) + + // Set up devfile registry host for route + devfileRegistryRoute, _ := deploy.GetSpecRoute(deployContext, "devfile-registry", "devfile-registry", "devfile-registry", 8080, "") + cl.Update(context.TODO(), devfileRegistryRoute) + + // Set up plugin registry host for route + pluginRegistryRoute, _ := deploy.GetSpecRoute(deployContext, "plugin-registry", "plugin-registry", "plugin-registry", 8080, "") + cl.Update(context.TODO(), pluginRegistryRoute) + + _, err = r.Reconcile(req) + if err != nil { + t.Fatalf("reconcile: (%v)", err) + } + _, err = r.Reconcile(req) + if err != nil { + t.Fatalf("reconcile: (%v)", err) + } + + cheCm := &corev1.ConfigMap{} + if err := cl.Get(context.TODO(), types.NamespacedName{Name: "che", Namespace: cheCR.Namespace}, cheCm); err != nil { + t.Errorf("ConfigMap %s not found: %s", cheCm.Name, err) + } + + cheAPIInternal := cheCm.Data["CHE_API_INTERNAL"] + cheAPIInternalExpected := "http://che-host.eclipse-che.svc:8080/api" + if cheAPIInternal != cheAPIInternalExpected { + t.Fatalf("Che API internal url must be %s", cheAPIInternalExpected) + } + + pluginRegistryInternal := cheCm.Data["CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL"] + pluginRegistryInternalExpected := "http://plugin-registry.eclipse-che.svc:8080/v3" + if pluginRegistryInternal != pluginRegistryInternalExpected { + t.Fatalf("Plugin registry internal url must be %s", pluginRegistryInternalExpected) + } + + devRegistryInternal := cheCm.Data["CHE_WORKSPACE_DEVFILE__REGISTRY__INTERNAL__URL"] + devRegistryInternalExpected := "http://devfile-registry.eclipse-che.svc:8080" + if devRegistryInternal != devRegistryInternalExpected { + t.Fatalf("Devfile registry internal url must be %s", pluginRegistryInternalExpected) + } + + // update CR and make sure Che configmap has been updated + cheCR.Spec.Server.UseInternalClusterSVCNames = false + if err := cl.Update(context.TODO(), cheCR); err != nil { + t.Error("Failed to update CheCluster custom resource") + } + + _, err = r.Reconcile(req) + if err != nil { + t.Fatalf("reconcile: (%v)", err) + } + + cheCmWithDisabledInternalClusterSVCNames := &corev1.ConfigMap{} + if err := cl.Get(context.TODO(), types.NamespacedName{Name: "che", Namespace: cheCR.Namespace}, cheCmWithDisabledInternalClusterSVCNames); err != nil { + t.Errorf("ConfigMap %s not found: %s", cheCm.Name, err) + } + + cheAPIInternal = cheCmWithDisabledInternalClusterSVCNames.Data["CHE_API_INTERNAL"] + cheAPIInternalExpected = "http://che-host/api" + if cheAPIInternal != cheAPIInternalExpected { + t.Fatalf("Che API internal url must be %s", cheAPIInternalExpected) + } + + pluginRegistryInternal = cheCmWithDisabledInternalClusterSVCNames.Data["CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL"] + pluginRegistryInternalExpected = "http://plugin-registry/v3" + if pluginRegistryInternal != pluginRegistryInternalExpected { + t.Fatalf("Plugin registry internal url must be %s", pluginRegistryInternalExpected) + } + + devRegistryInternal = cheCmWithDisabledInternalClusterSVCNames.Data["CHE_WORKSPACE_DEVFILE__REGISTRY__INTERNAL__URL"] + devRegistryInternalExpected = "http://devfile-registry" + if devRegistryInternal != devRegistryInternalExpected { + t.Fatalf("Plugin registry internal url must be %s", pluginRegistryInternalExpected) + } +} + func Init() (client.Client, runtime.Scheme) { pgPod := &corev1.Pod{ TypeMeta: metav1.TypeMeta{ diff --git a/pkg/deploy/data_types.go b/pkg/deploy/data_types.go index be3449d66..acfbe1d35 100644 --- a/pkg/deploy/data_types.go +++ b/pkg/deploy/data_types.go @@ -25,12 +25,19 @@ type ProvisioningStatus struct { } type DeployContext struct { - CheCluster *orgv1.CheCluster - ClusterAPI ClusterAPI - Proxy *Proxy + CheCluster *orgv1.CheCluster + ClusterAPI ClusterAPI + Proxy *Proxy + InternalService InternalService DefaultCheHost string } +type InternalService struct { + DevfileRegistryHost string + PluginRegistryHost string + CheHost string +} + type ClusterAPI struct { Client client.Client Scheme *runtime.Scheme diff --git a/pkg/deploy/defaults.go b/pkg/deploy/defaults.go index bdc92689a..c104fa5fb 100644 --- a/pkg/deploy/defaults.go +++ b/pkg/deploy/defaults.go @@ -61,6 +61,7 @@ const ( DefaultPluginRegistryMemoryLimit = "256Mi" DefaultPluginRegistryMemoryRequest = "16Mi" + // DefaultKube DefaultDevfileRegistryMemoryLimit = "256Mi" DefaultDevfileRegistryMemoryRequest = "16Mi" DefaultKeycloakAdminUserName = "admin" diff --git a/pkg/deploy/devfile-registry/devfile_registry.go b/pkg/deploy/devfile-registry/devfile_registry.go index ea06f928b..e40efe77b 100644 --- a/pkg/deploy/devfile-registry/devfile_registry.go +++ b/pkg/deploy/devfile-registry/devfile_registry.go @@ -73,6 +73,8 @@ func SyncDevfileRegistryToCluster(deployContext *deploy.DeployContext, cheHost s } } + deployContext.InternalService.DevfileRegistryHost = fmt.Sprintf("http://%s.%s.svc:8080", deploy.DevfileRegistry, deployContext.CheCluster.Namespace) + // Deploy devfile registry deploymentStatus := SyncDevfileRegistryDeploymentToCluster(deployContext) if !util.IsTestMode() { diff --git a/pkg/deploy/expose/expose.go b/pkg/deploy/expose/expose.go index 7c5bae938..adc74c209 100644 --- a/pkg/deploy/expose/expose.go +++ b/pkg/deploy/expose/expose.go @@ -98,22 +98,19 @@ func Expose(deployContext *deploy.DeployContext, cheHost string, endpointName st } else { // the empty string for a host is intentional here - we let OpenShift decide on the hostname route, err := deploy.SyncRouteToCluster(deployContext, endpointName, "", endpointName, 8080, additionalLabels) - if !util.IsTestMode() { - if route == nil { - logrus.Infof("Waiting on route '%s' to be ready", endpointName) - if err != nil { - logrus.Error(err) - } - - return "", false, err + if route == nil { + logrus.Infof("Waiting on route '%s' to be ready", endpointName) + if err != nil { + logrus.Error(err) } + return "", false, err } + if err := gateway.DeleteGatewayRouteConfig(gatewayConfig, deployContext); !util.IsTestMode() && err != nil { logrus.Error(err) } - if !util.IsTestMode() { - endpoint = route.Spec.Host - } + + endpoint = route.Spec.Host } } return endpoint, true, nil diff --git a/pkg/deploy/plugin-registry/plugin_registry.go b/pkg/deploy/plugin-registry/plugin_registry.go index 83b8f81a2..159d49508 100644 --- a/pkg/deploy/plugin-registry/plugin_registry.go +++ b/pkg/deploy/plugin-registry/plugin_registry.go @@ -74,6 +74,8 @@ func SyncPluginRegistryToCluster(deployContext *deploy.DeployContext, cheHost st } } + deployContext.InternalService.PluginRegistryHost = fmt.Sprintf("http://%s.%s.svc:8080/v3", deploy.PluginRegistry, deployContext.CheCluster.Namespace) + // Deploy plugin registry deploymentStatus := SyncPluginRegistryDeploymentToCluster(deployContext) if !util.IsTestMode() { diff --git a/pkg/deploy/server/che_configmap.go b/pkg/deploy/server/che_configmap.go index 1e52e6a6b..a0ae4749a 100644 --- a/pkg/deploy/server/che_configmap.go +++ b/pkg/deploy/server/che_configmap.go @@ -40,6 +40,7 @@ type CheConfigMap struct { CheMultiUser string `json:"CHE_MULTIUSER"` ChePort string `json:"CHE_PORT"` CheApi string `json:"CHE_API"` + CheApiInternal string `json:"CHE_API_INTERNAL"` CheWebSocketEndpoint string `json:"CHE_WEBSOCKET_ENDPOINT"` CheDebugServer string `json:"CHE_DEBUG_SERVER"` CheMetricsEnabled string `json:"CHE_METRICS_ENABLED"` @@ -70,7 +71,9 @@ type CheConfigMap struct { WorkspaceHttpsProxy string `json:"CHE_WORKSPACE_HTTPS__PROXY"` WorkspaceNoProxy string `json:"CHE_WORKSPACE_NO__PROXY"` PluginRegistryUrl string `json:"CHE_WORKSPACE_PLUGIN__REGISTRY__URL,omitempty"` + PluginRegistryInternalUrl string `json:"CHE_WORKSPACE_PLUGIN__REGISTRY__INTERNAL__URL,omitempty"` DevfileRegistryUrl string `json:"CHE_WORKSPACE_DEVFILE__REGISTRY__URL,omitempty"` + DevfileRegistryInternalUrl string `json:"CHE_WORKSPACE_DEVFILE__REGISTRY__INTERNAL__URL,omitempty"` WebSocketEndpointMinor string `json:"CHE_WEBSOCKET_ENDPOINT__MINOR"` CheWorkspacePluginBrokerMetadataImage string `json:"CHE_WORKSPACE_PLUGIN__BROKER_METADATA_IMAGE,omitempty"` CheWorkspacePluginBrokerArtifactsImage string `json:"CHE_WORKSPACE_PLUGIN__BROKER_ARTIFACTS_IMAGE,omitempty"` @@ -168,8 +171,8 @@ func GetCheConfigMapData(deployContext *deploy.DeployContext) (cheEnv map[string keycloakClientId := util.GetValue(deployContext.CheCluster.Spec.Auth.IdentityProviderClientId, cheFlavor+"-public") ingressStrategy := util.GetServerExposureStrategy(deployContext.CheCluster, deploy.DefaultServerExposureStrategy) ingressClass := util.GetValue(deployContext.CheCluster.Spec.K8s.IngressClass, deploy.DefaultIngressClass) - devfileRegistryUrl := deployContext.CheCluster.Status.DevfileRegistryURL - pluginRegistryUrl := deployContext.CheCluster.Status.PluginRegistryURL + devfileRegistryURL:= deployContext.CheCluster.Status.DevfileRegistryURL + pluginRegistryURL := deployContext.CheCluster.Status.PluginRegistryURL cheLogLevel := util.GetValue(deployContext.CheCluster.Spec.Server.CheLogLevel, deploy.DefaultCheLogLevel) cheDebug := util.GetValue(deployContext.CheCluster.Spec.Server.CheDebug, deploy.DefaultCheDebug) cheMetrics := strconv.FormatBool(deployContext.CheCluster.Spec.Metrics.Enable) @@ -178,11 +181,26 @@ func GetCheConfigMapData(deployContext *deploy.DeployContext) (cheEnv map[string workspaceExposure := deploy.GetSingleHostExposureType(deployContext.CheCluster) singleHostGatewayConfigMapLabels := labels.FormatLabels(util.GetMapValue(deployContext.CheCluster.Spec.Server.SingleHostGatewayConfigMapLabels, deploy.DefaultSingleHostGatewayConfigMapLabels)) + cheAPI := protocol + "://" + cheHost + "/api" + + var pluginRegistryInternalURL, devfileRegistryInternalURL, cheInternalAPI string + + if deployContext.CheCluster.Spec.Server.UseInternalClusterSVCNames { + devfileRegistryInternalURL = deployContext.InternalService.DevfileRegistryHost + pluginRegistryInternalURL = deployContext.InternalService.PluginRegistryHost + cheInternalAPI = deployContext.InternalService.CheHost + "/api" + } else { + devfileRegistryInternalURL = devfileRegistryURL + pluginRegistryInternalURL = pluginRegistryURL + cheInternalAPI = cheAPI + } + data := &CheConfigMap{ CheMultiUser: cheMultiUser, CheHost: cheHost, ChePort: "8080", - CheApi: protocol + "://" + cheHost + "/api", + CheApi: cheAPI, + CheApiInternal: cheInternalAPI, CheWebSocketEndpoint: wsprotocol + "://" + cheHost + "/api/websocket", WebSocketEndpointMinor: wsprotocol + "://" + cheHost + "/api/websocket-minor", CheDebugServer: cheDebug, @@ -206,8 +224,10 @@ func GetCheConfigMapData(deployContext *deploy.DeployContext) (cheEnv map[string WorkspaceHttpProxy: deployContext.Proxy.HttpProxy, WorkspaceHttpsProxy: deployContext.Proxy.HttpsProxy, WorkspaceNoProxy: cheWorkspaceNoProxy, - PluginRegistryUrl: pluginRegistryUrl, - DevfileRegistryUrl: devfileRegistryUrl, + PluginRegistryUrl: pluginRegistryURL, + PluginRegistryInternalUrl: pluginRegistryInternalURL, + DevfileRegistryUrl: devfileRegistryURL, + DevfileRegistryInternalUrl: devfileRegistryInternalURL, CheWorkspacePluginBrokerMetadataImage: deploy.DefaultCheWorkspacePluginBrokerMetadataImage(deployContext.CheCluster), CheWorkspacePluginBrokerArtifactsImage: deploy.DefaultCheWorkspacePluginBrokerArtifactsImage(deployContext.CheCluster), CheServerSecureExposerJwtProxyImage: deploy.DefaultCheServerSecureExposerJwtProxyImage(deployContext.CheCluster),