diff --git a/build/scripts/minikube-tests/test-operator.sh b/build/scripts/minikube-tests/test-operator.sh index 9a892fb4f9..4b52db9d39 100755 --- a/build/scripts/minikube-tests/test-operator.sh +++ b/build/scripts/minikube-tests/test-operator.sh @@ -30,6 +30,75 @@ runTest() { yq -riSY '.spec.template.spec.containers[0].image = "'${OPERATOR_IMAGE}'"' "${CURRENT_OPERATOR_VERSION_TEMPLATE_PATH}/che-operator/kubernetes/operator.yaml" yq -riSY '.spec.template.spec.containers[0].imagePullPolicy = "IfNotPresent"' "${CURRENT_OPERATOR_VERSION_TEMPLATE_PATH}/che-operator/kubernetes/operator.yaml" + cat > /tmp/patch.yaml < routeName = strconv.Itoa(e.TargetPort) } - path = fmt.Sprintf("/%s/%s", componentName, routeName) + path = fmt.Sprintf("/%s", routeName) return routeName, path } @@ -715,20 +764,20 @@ func getServiceURL(port int32, workspaceID string, workspaceNamespace string) st return fmt.Sprintf("http://%s.%s.svc:%d", common.ServiceName(workspaceID), workspaceNamespace, port) } -func getPublicURLPrefixForEndpoint(workspaceID string, machineName string, endpoint dwo.Endpoint) string { +func getPublicURLPrefixForEndpoint(dwName string, username string, endpoint dwo.Endpoint) string { endpointName := "" if endpoint.Attributes.GetString(uniqueEndpointAttributeName, nil) == "true" { endpointName = endpoint.Name } - return getPublicURLPrefix(workspaceID, machineName, int32(endpoint.TargetPort), endpointName) + return getPublicURLPrefix(dwName, username, int32(endpoint.TargetPort), endpointName) } -func getPublicURLPrefix(workspaceID string, machineName string, port int32, uniqueEndpointName string) string { +func getPublicURLPrefix(dwName string, username string, port int32, uniqueEndpointName string) string { if uniqueEndpointName == "" { - return fmt.Sprintf(endpointURLPrefixPattern, workspaceID, machineName, port) + return fmt.Sprintf(endpointURLPrefixPattern, username, dwName, port) } - return fmt.Sprintf(uniqueEndpointURLPrefixPattern, workspaceID, machineName, uniqueEndpointName) + return fmt.Sprintf(uniqueEndpointURLPrefixPattern, username, dwName, uniqueEndpointName) } func determineEndpointScheme(e dwo.Endpoint) string { diff --git a/controllers/devworkspace/solver/che_routing_test.go b/controllers/devworkspace/solver/che_routing_test.go index 4aa9ab9831..252a15749d 100644 --- a/controllers/devworkspace/solver/che_routing_test.go +++ b/controllers/devworkspace/solver/che_routing_test.go @@ -47,6 +47,7 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" + "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/yaml" ) @@ -68,7 +69,7 @@ func createTestScheme() *runtime.Scheme { func getSpecObjectsForManager(t *testing.T, mgr *chev2.CheCluster, routing *dwo.DevWorkspaceRouting, additionalInitialObjects ...runtime.Object) (client.Client, solvers.RoutingSolver, solvers.RoutingObjects) { scheme := createTestScheme() - allObjs := []runtime.Object{mgr} + allObjs := []runtime.Object{mgr, routing} for i := range additionalInitialObjects { allObjs = append(allObjs, additionalInitialObjects[i]) } @@ -97,6 +98,26 @@ func getSpecObjectsForManager(t *testing.T, mgr *chev2.CheCluster, routing *dwo. t.Fatal(err) } + // set owner references for the routing objects + for idx := range objs.Services { + err := controllerutil.SetControllerReference(routing, &objs.Services[idx], scheme) + if err != nil { + t.Fatal(err) + } + } + for idx := range objs.Ingresses { + err := controllerutil.SetControllerReference(routing, &objs.Ingresses[idx], scheme) + if err != nil { + t.Fatal(err) + } + } + for idx := range objs.Routes { + err := controllerutil.SetControllerReference(routing, &objs.Routes[idx], scheme) + if err != nil { + t.Fatal(err) + } + } + // now we need a second round of che manager reconciliation so that it proclaims the che gateway as established cheRecon.Reconcile(context.TODO(), reconcile.Request{NamespacedName: types.NamespacedName{Name: "che", Namespace: "ns"}}) @@ -116,7 +137,7 @@ func getSpecObjects(t *testing.T, routing *dwo.DevWorkspaceRouting) (client.Clie Hostname: "over.the.rainbow", }, }, - }, routing) + }, routing, userProfileSecret()) } func subdomainDevWorkspaceRouting() *dwo.DevWorkspaceRouting { @@ -124,6 +145,14 @@ func subdomainDevWorkspaceRouting() *dwo.DevWorkspaceRouting { ObjectMeta: metav1.ObjectMeta{ Name: "routing", Namespace: "ws", + OwnerReferences: []metav1.OwnerReference{ + { + APIVersion: "workspace.devfile.io/v1alpha2", + Kind: "DevWorkspace", + Name: "my-workspace", + UID: "uid", + }, + }, }, Spec: dwo.DevWorkspaceRoutingSpec{ DevWorkspaceId: "wsid", @@ -161,6 +190,14 @@ func relocatableDevWorkspaceRouting() *dwo.DevWorkspaceRouting { ObjectMeta: metav1.ObjectMeta{ Name: "routing", Namespace: "ws", + OwnerReferences: []metav1.OwnerReference{ + { + APIVersion: "workspace.devfile.io/v1alpha2", + Kind: "DevWorkspace", + Name: "my-workspace", + UID: "uid", + }, + }, }, Spec: dwo.DevWorkspaceRoutingSpec{ DevWorkspaceId: "wsid", @@ -203,6 +240,19 @@ func relocatableDevWorkspaceRouting() *dwo.DevWorkspaceRouting { } } +func userProfileSecret() *corev1.Secret { + return &corev1.Secret{ + ObjectMeta: metav1.ObjectMeta{ + Name: "user-profile", + Namespace: "ws", + Finalizers: []string{controller.FinalizerName}, + }, + Data: map[string][]byte{ + "name": []byte("username"), + }, + } +} + func TestCreateRelocatedObjectsK8S(t *testing.T) { infrastructure.InitializeForTesting(infrastructure.Kubernetes) cl, _, objs := getSpecObjects(t, relocatableDevWorkspaceRouting()) @@ -344,7 +394,7 @@ func TestCreateRelocatedObjectsK8S(t *testing.T) { healthzName := "wsid-9999-healthz" assert.Contains(t, workspaceMainConfig.HTTP.Routers, healthzName) assert.Equal(t, workspaceMainConfig.HTTP.Routers[healthzName].Service, wsid) - assert.Equal(t, workspaceMainConfig.HTTP.Routers[healthzName].Rule, "Path(`/wsid/m1/9999/healthz`)") + assert.Equal(t, workspaceMainConfig.HTTP.Routers[healthzName].Rule, "Path(`/username/my-workspace/9999/healthz`)") assert.NotContains(t, workspaceMainConfig.HTTP.Routers[healthzName].Middlewares, "wsid"+gateway.AuthMiddlewareSuffix) assert.Contains(t, workspaceMainConfig.HTTP.Routers[healthzName].Middlewares, "wsid"+gateway.StripPrefixMiddlewareSuffix) assert.NotContains(t, workspaceMainConfig.HTTP.Routers[healthzName].Middlewares, "wsid"+gateway.HeaderRewriteMiddlewareSuffix) @@ -354,7 +404,7 @@ func TestCreateRelocatedObjectsK8S(t *testing.T) { healthzName := "wsid-m1-9999-healthz" assert.Contains(t, workspaceConfig.HTTP.Routers, healthzName) assert.Equal(t, workspaceConfig.HTTP.Routers[healthzName].Service, healthzName) - assert.Equal(t, workspaceConfig.HTTP.Routers[healthzName].Rule, "Path(`/m1/9999/healthz`)") + assert.Equal(t, workspaceConfig.HTTP.Routers[healthzName].Rule, "Path(`/9999/healthz`)") assert.NotContains(t, workspaceConfig.HTTP.Routers[healthzName].Middlewares, healthzName+gateway.AuthMiddlewareSuffix) assert.Contains(t, workspaceConfig.HTTP.Routers[healthzName].Middlewares, healthzName+gateway.StripPrefixMiddlewareSuffix) }) @@ -449,7 +499,7 @@ func TestCreateRelocatedObjectsOpenshift(t *testing.T) { healthzName := "wsid-9999-healthz" assert.Contains(t, workspaceMainConfig.HTTP.Routers, healthzName) assert.Equal(t, workspaceMainConfig.HTTP.Routers[healthzName].Service, wsid) - assert.Equal(t, workspaceMainConfig.HTTP.Routers[healthzName].Rule, "Path(`/wsid/m1/9999/healthz`)") + assert.Equal(t, workspaceMainConfig.HTTP.Routers[healthzName].Rule, "Path(`/username/my-workspace/9999/healthz`)") assert.NotContains(t, workspaceMainConfig.HTTP.Routers[healthzName].Middlewares, "wsid"+gateway.AuthMiddlewareSuffix) assert.Contains(t, workspaceMainConfig.HTTP.Routers[healthzName].Middlewares, "wsid"+gateway.StripPrefixMiddlewareSuffix) assert.Contains(t, workspaceMainConfig.HTTP.Routers[healthzName].Middlewares, "wsid"+gateway.HeaderRewriteMiddlewareSuffix) @@ -459,7 +509,7 @@ func TestCreateRelocatedObjectsOpenshift(t *testing.T) { healthzName := "wsid-m1-9999-healthz" assert.Contains(t, workspaceConfig.HTTP.Routers, healthzName) assert.Equal(t, workspaceConfig.HTTP.Routers[healthzName].Service, healthzName) - assert.Equal(t, workspaceConfig.HTTP.Routers[healthzName].Rule, "Path(`/m1/9999/healthz`)") + assert.Equal(t, workspaceConfig.HTTP.Routers[healthzName].Rule, "Path(`/9999/healthz`)") assert.NotContains(t, workspaceConfig.HTTP.Routers[healthzName].Middlewares, healthzName+gateway.AuthMiddlewareSuffix) assert.Contains(t, workspaceConfig.HTTP.Routers[healthzName].Middlewares, healthzName+gateway.StripPrefixMiddlewareSuffix) }) @@ -474,6 +524,14 @@ func TestUniqueMainEndpoint(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "routing", Namespace: "ws", + OwnerReferences: []metav1.OwnerReference{ + { + APIVersion: "workspace.devfile.io/v1alpha2", + Kind: "DevWorkspace", + Name: "my-workspace", + UID: "uid", + }, + }, }, Spec: dwo.DevWorkspaceRoutingSpec{ DevWorkspaceId: wsid, @@ -525,7 +583,7 @@ func TestUniqueMainEndpoint(t *testing.T) { healthzName := wsid + "-e1-healthz" assert.Contains(t, workspaceMainConfig.HTTP.Routers, healthzName) assert.Equal(t, workspaceMainConfig.HTTP.Routers[healthzName].Service, wsid) - assert.Equal(t, workspaceMainConfig.HTTP.Routers[healthzName].Rule, "Path(`/"+wsid+"/m1/e1/healthz`)") + assert.Equal(t, workspaceMainConfig.HTTP.Routers[healthzName].Rule, "Path(`/username/my-workspace/e1/healthz`)") assert.NotContains(t, workspaceMainConfig.HTTP.Routers[healthzName].Middlewares, wsid+gateway.AuthMiddlewareSuffix) assert.Contains(t, workspaceMainConfig.HTTP.Routers[healthzName].Middlewares, wsid+gateway.StripPrefixMiddlewareSuffix) assert.Contains(t, workspaceMainConfig.HTTP.Routers[healthzName].Middlewares, wsid+gateway.HeaderRewriteMiddlewareSuffix) @@ -535,7 +593,7 @@ func TestUniqueMainEndpoint(t *testing.T) { healthzName := wsid + "-m1-e1-healthz" assert.Contains(t, workspaceConfig.HTTP.Routers, healthzName) assert.Equal(t, workspaceConfig.HTTP.Routers[healthzName].Service, healthzName) - assert.Equal(t, workspaceConfig.HTTP.Routers[healthzName].Rule, "Path(`/m1/e1/healthz`)") + assert.Equal(t, workspaceConfig.HTTP.Routers[healthzName].Rule, "Path(`/e1/healthz`)") assert.NotContains(t, workspaceConfig.HTTP.Routers[healthzName].Middlewares, healthzName+gateway.AuthMiddlewareSuffix) assert.Contains(t, workspaceConfig.HTTP.Routers[healthzName].Middlewares, healthzName+gateway.StripPrefixMiddlewareSuffix) }) @@ -590,14 +648,14 @@ func TestCreateSubDomainObjects(t *testing.T) { if len(objs.Ingresses) != 3 { t.Error("Expected 3 ingress, found ", len(objs.Ingresses)) } - if objs.Ingresses[0].Spec.Rules[0].Host != "wsid-1.down.on.earth" { - t.Error("Expected Ingress host 'wsid-1.down.on.earth', but got ", objs.Ingresses[0].Spec.Rules[0].Host) + if objs.Ingresses[0].Spec.Rules[0].Host != "username.my-workspace.e1.down.on.earth" { + t.Error("Expected Ingress host 'username.my-workspace.e1.down.on.earth', but got ", objs.Ingresses[0].Spec.Rules[0].Host) } - if objs.Ingresses[1].Spec.Rules[0].Host != "wsid-2.down.on.earth" { - t.Error("Expected Ingress host 'wsid-2.down.on.earth', but got ", objs.Ingresses[1].Spec.Rules[0].Host) + if objs.Ingresses[1].Spec.Rules[0].Host != "username.my-workspace.e2.down.on.earth" { + t.Error("Expected Ingress host 'username.my-workspace.e2.down.on.earth', but got ", objs.Ingresses[1].Spec.Rules[0].Host) } - if objs.Ingresses[2].Spec.Rules[0].Host != "wsid-3.down.on.earth" { - t.Error("Expected Ingress host 'wsid-3.down.on.earth', but got ", objs.Ingresses[2].Spec.Rules[0].Host) + if objs.Ingresses[2].Spec.Rules[0].Host != "username.my-workspace.e3.down.on.earth" { + t.Error("Expected Ingress host 'username.my-workspace.e3.down.on.earth', but got ", objs.Ingresses[2].Spec.Rules[0].Host) } }) @@ -606,8 +664,8 @@ func TestCreateSubDomainObjects(t *testing.T) { if len(objs.Routes) != 3 { t.Error("Expected 3 Routes, found ", len(objs.Routes)) } - if objs.Routes[0].Spec.Host != "wsid-1.down.on.earth" { - t.Error("Expected Route host 'wsid-1.down.on.earth', but got ", objs.Routes[0].Spec.Host) + if objs.Routes[0].Spec.Host != "username.my-workspace.e1.down.on.earth" { + t.Error("Expected Route host 'username.my-workspace.e1.down.on.earth', but got ", objs.Routes[0].Spec.Host) } }) } @@ -645,24 +703,24 @@ func TestReportRelocatableExposedEndpoints(t *testing.T) { if e1.Name != "e1" { t.Errorf("The first endpoint should have been e1 but is %s", e1.Name) } - if e1.Url != "https://over.the.rainbow/wsid/m1/9999/1/" { - t.Errorf("The e1 endpoint should have the following URL: '%s' but has '%s'.", "https://over.the.rainbow/wsid/m1/9999/1/", e1.Url) + if e1.Url != "https://over.the.rainbow/username/my-workspace/9999/1/" { + t.Errorf("The e1 endpoint should have the following URL: '%s' but has '%s'.", "https://over.the.rainbow/username/my-workspace/9999/1/", e1.Url) } e2 := m1[1] if e2.Name != "e2" { t.Errorf("The second endpoint should have been e2 but is %s", e1.Name) } - if e2.Url != "https://over.the.rainbow/wsid/m1/9999/2.js" { - t.Errorf("The e2 endpoint should have the following URL: '%s' but has '%s'.", "https://over.the.rainbow/wsid/m1/9999/2.js", e2.Url) + if e2.Url != "https://over.the.rainbow/username/my-workspace/9999/2.js" { + t.Errorf("The e2 endpoint should have the following URL: '%s' but has '%s'.", "https://over.the.rainbow/username/my-workspace/9999/2.js", e2.Url) } e3 := m1[2] if e3.Name != "e3" { t.Errorf("The third endpoint should have been e3 but is %s", e1.Name) } - if e3.Url != "https://over.the.rainbow/wsid/m1/9999/" { - t.Errorf("The e3 endpoint should have the following URL: '%s' but has '%s'.", "https://over.the.rainbow/wsid/m1/9999/", e3.Url) + if e3.Url != "https://over.the.rainbow/username/my-workspace/9999/" { + t.Errorf("The e3 endpoint should have the following URL: '%s' but has '%s'.", "https://over.the.rainbow/username/my-workspace/9999/", e3.Url) } } @@ -673,6 +731,14 @@ func TestExposeEndpoints(t *testing.T) { ObjectMeta: metav1.ObjectMeta{ Name: "routing", Namespace: "ws", + OwnerReferences: []metav1.OwnerReference{ + { + APIVersion: "workspace.devfile.io/v1alpha2", + Kind: "DevWorkspace", + Name: "my-workspace", + UID: "uid", + }, + }, }, Spec: dwo.DevWorkspaceRoutingSpec{ DevWorkspaceId: "wsid", @@ -767,13 +833,13 @@ func TestExposeEndpoints(t *testing.T) { assert.True(t, ok) assert.Equal(t, 1, len(sp)) assert.Equal(t, "server-pub", sp[0].Name) - assert.Equal(t, "https://over.the.rainbow/wsid/server-public/8082/", sp[0].Url) + assert.Equal(t, "https://over.the.rainbow/username/my-workspace/8082/", sp[0].Url) spnr, ok := exposed["server-public-no-rewrite"] assert.True(t, ok) assert.Equal(t, 1, len(spnr)) assert.Equal(t, "server-pub-nr", spnr[0].Name) - assert.Equal(t, "http://wsid-1.down.on.earth/", spnr[0].Url) + assert.Equal(t, "http://username.my-workspace.server-pub-nr.down.on.earth/", spnr[0].Url) } func TestReportSubdomainExposedEndpoints(t *testing.T) { @@ -807,24 +873,24 @@ func TestReportSubdomainExposedEndpoints(t *testing.T) { if e1.Name != "e1" { t.Errorf("The first endpoint should have been e1 but is %s", e1.Name) } - if e1.Url != "https://wsid-1.down.on.earth/1/" { - t.Errorf("The e1 endpoint should have the following URL: '%s' but has '%s'.", "https://wsid-1.down.on.earth/1/", e1.Url) + if e1.Url != "https://username.my-workspace.e1.down.on.earth/1/" { + t.Errorf("The e1 endpoint should have the following URL: '%s' but has '%s'.", "https://username.my-workspace.e1.down.on.earth/1/", e1.Url) } e2 := m1[1] if e2.Name != "e2" { t.Errorf("The second endpoint should have been e2 but is %s", e1.Name) } - if e2.Url != "https://wsid-2.down.on.earth/2.js" { - t.Errorf("The e2 endpoint should have the following URL: '%s' but has '%s'.", "https://wsid-2.down.on.earth/2.js", e2.Url) + if e2.Url != "https://username.my-workspace.e2.down.on.earth/2.js" { + t.Errorf("The e2 endpoint should have the following URL: '%s' but has '%s'.", "https://username.my-workspace.e2.down.on.earth/2.js", e2.Url) } e3 := m1[2] if e3.Name != "e3" { t.Errorf("The third endpoint should have been e3 but is %s", e1.Name) } - if e3.Url != "http://wsid-3.down.on.earth/" { - t.Errorf("The e3 endpoint should have the following URL: '%s' but has '%s'.", "https://wsid-3.down.on.earth/", e3.Url) + if e3.Url != "http://username.my-workspace.e3.down.on.earth/" { + t.Errorf("The e3 endpoint should have the following URL: '%s' but has '%s'.", "http://username.my-workspace.e3.down.on.earth/", e3.Url) } } @@ -892,7 +958,7 @@ func TestUsesIngressAnnotationsForWorkspaceEndpointIngresses(t *testing.T) { }, } - _, _, objs := getSpecObjectsForManager(t, mgr, subdomainDevWorkspaceRouting()) + _, _, objs := getSpecObjectsForManager(t, mgr, subdomainDevWorkspaceRouting(), userProfileSecret()) if len(objs.Ingresses) != 3 { t.Fatalf("Unexpected number of generated ingresses: %d", len(objs.Ingresses)) @@ -927,7 +993,7 @@ func TestUsesCustomCertificateForWorkspaceEndpointIngresses(t *testing.T) { }, } - _, _, objs := getSpecObjectsForManager(t, mgr, subdomainDevWorkspaceRouting(), &corev1.Secret{ + _, _, objs := getSpecObjectsForManager(t, mgr, subdomainDevWorkspaceRouting(), userProfileSecret(), &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: "tlsSecret", Namespace: "ns", @@ -956,7 +1022,7 @@ func TestUsesCustomCertificateForWorkspaceEndpointIngresses(t *testing.T) { t.Fatalf("Unexpected number of host records on the TLS spec: %d", len(ingress.Spec.TLS[0].Hosts)) } - if ingress.Spec.TLS[0].Hosts[0] != "wsid-1.almost.trivial" { + if ingress.Spec.TLS[0].Hosts[0] != "username.my-workspace.e1.almost.trivial" { t.Errorf("Unexpected host name of the TLS spec: %s", ingress.Spec.TLS[0].Hosts[0]) } @@ -974,7 +1040,7 @@ func TestUsesCustomCertificateForWorkspaceEndpointIngresses(t *testing.T) { t.Fatalf("Unexpected number of host records on the TLS spec: %d", len(ingress.Spec.TLS[0].Hosts)) } - if ingress.Spec.TLS[0].Hosts[0] != "wsid-2.almost.trivial" { + if ingress.Spec.TLS[0].Hosts[0] != "username.my-workspace.e2.almost.trivial" { t.Errorf("Unexpected host name of the TLS spec: %s", ingress.Spec.TLS[0].Hosts[0]) } @@ -1003,7 +1069,7 @@ func TestUsesCustomCertificateForWorkspaceEndpointRoutes(t *testing.T) { }, } - _, _, objs := getSpecObjectsForManager(t, mgr, subdomainDevWorkspaceRouting(), &corev1.Secret{ + _, _, objs := getSpecObjectsForManager(t, mgr, subdomainDevWorkspaceRouting(), userProfileSecret(), &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ Name: "tlsSecret", Namespace: "ns", diff --git a/controllers/devworkspace/solver/endpoint_exposer.go b/controllers/devworkspace/solver/endpoint_exposer.go index 6ee93062a8..dd8ce06aa6 100644 --- a/controllers/devworkspace/solver/endpoint_exposer.go +++ b/controllers/devworkspace/solver/endpoint_exposer.go @@ -142,7 +142,7 @@ func (e *IngressExposer) initFrom(ctx context.Context, cl client.Client, cluster return nil } -func (e *RouteExposer) getRouteForService(endpoint *EndpointInfo) routev1.Route { +func (e *RouteExposer) getRouteForService(endpoint *EndpointInfo, username string, dwName string) routev1.Route { targetEndpoint := intstr.FromInt(int(endpoint.port)) labels := labels.Merge( e.labels, @@ -159,7 +159,7 @@ func (e *RouteExposer) getRouteForService(endpoint *EndpointInfo) routev1.Route OwnerReferences: endpoint.service.OwnerReferences, }, Spec: routev1.RouteSpec{ - Host: hostName(endpoint.order, e.devWorkspaceID, e.baseDomain), + Host: hostName(username, dwName, endpoint.endpointName, e.baseDomain), To: routev1.RouteTargetReference{ Kind: "Service", Name: endpoint.service.Name, @@ -185,8 +185,8 @@ func (e *RouteExposer) getRouteForService(endpoint *EndpointInfo) routev1.Route return route } -func (e *IngressExposer) getIngressForService(endpoint *EndpointInfo) networkingv1.Ingress { - hostname := hostName(endpoint.order, e.devWorkspaceID, e.baseDomain) +func (e *IngressExposer) getIngressForService(endpoint *EndpointInfo, username string, dwName string) networkingv1.Ingress { + hostname := hostName(username, dwName, endpoint.endpointName, e.baseDomain) ingressPathType := networkingv1.PathTypeImplementationSpecific ingress := networkingv1.Ingress{ @@ -239,8 +239,8 @@ func (e *IngressExposer) getIngressForService(endpoint *EndpointInfo) networking return ingress } -func hostName(order int, workspaceID string, baseDomain string) string { - return fmt.Sprintf("%s-%d.%s", workspaceID, order, baseDomain) +func hostName(username string, workspaceName string, endpointName string, baseDomain string) string { + return fmt.Sprintf("%s.%s.%s.%s", username, workspaceName, endpointName, baseDomain) } func routeAnnotations(machineName string, endpointName string) map[string]string { diff --git a/deploy/deployment/kubernetes/combined.yaml b/deploy/deployment/kubernetes/combined.yaml index aee563e248..1c9ed7b2f5 100644 --- a/deploy/deployment/kubernetes/combined.yaml +++ b/deploy/deployment/kubernetes/combined.yaml @@ -8233,6 +8233,7 @@ rules: - create - watch - get + - update - delete - apiGroups: - apiextensions.k8s.io diff --git a/deploy/deployment/kubernetes/objects/che-operator.ClusterRole.yaml b/deploy/deployment/kubernetes/objects/che-operator.ClusterRole.yaml index 1820f247e9..71f3031429 100644 --- a/deploy/deployment/kubernetes/objects/che-operator.ClusterRole.yaml +++ b/deploy/deployment/kubernetes/objects/che-operator.ClusterRole.yaml @@ -236,6 +236,7 @@ rules: - create - watch - get + - update - delete - apiGroups: - apiextensions.k8s.io diff --git a/deploy/deployment/openshift/combined.yaml b/deploy/deployment/openshift/combined.yaml index 9295fe33ef..be196f080e 100644 --- a/deploy/deployment/openshift/combined.yaml +++ b/deploy/deployment/openshift/combined.yaml @@ -8233,6 +8233,7 @@ rules: - create - watch - get + - update - delete - apiGroups: - apiextensions.k8s.io diff --git a/deploy/deployment/openshift/objects/che-operator.ClusterRole.yaml b/deploy/deployment/openshift/objects/che-operator.ClusterRole.yaml index 1820f247e9..71f3031429 100644 --- a/deploy/deployment/openshift/objects/che-operator.ClusterRole.yaml +++ b/deploy/deployment/openshift/objects/che-operator.ClusterRole.yaml @@ -236,6 +236,7 @@ rules: - create - watch - get + - update - delete - apiGroups: - apiextensions.k8s.io diff --git a/helmcharts/next/templates/che-operator.ClusterRole.yaml b/helmcharts/next/templates/che-operator.ClusterRole.yaml index 1820f247e9..71f3031429 100644 --- a/helmcharts/next/templates/che-operator.ClusterRole.yaml +++ b/helmcharts/next/templates/che-operator.ClusterRole.yaml @@ -236,6 +236,7 @@ rules: - create - watch - get + - update - delete - apiGroups: - apiextensions.k8s.io