Skip to content

Commit

Permalink
feat: enable internal cluster SVC names usage by default
Browse files Browse the repository at this point in the history
Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha committed Jul 13, 2021
1 parent 78e5dba commit f67a5ce
Show file tree
Hide file tree
Showing 14 changed files with 84 additions and 83 deletions.
4 changes: 1 addition & 3 deletions deploy/crds/org_v1_che_cr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ metadata:
name: eclipse-che
spec:
server:
# Use internal cluster SVC names to communicate between components to speed up the traffic and avoid proxy issues.
useInternalClusterSVCNames: true
# Specifies a variation of the installation. The options are `che` for upstream Che installations, or `codeready` for link:https://developers.redhat.com/products/codeready-workspaces/overview[CodeReady Workspaces] installation.
# Override the default value only on necessary occasions.
cheFlavor: ''
Expand Down Expand Up @@ -161,7 +159,7 @@ spec:
# All the endpoints whether backed by the ingress or gateway `route` always point to the subpaths on the same domain. Defaults to `native`.
singleHostExposureType: ''
metrics:
# Enables `metrics` the Che server endpoint.
# Enables `metrics` the Che server endpoint.
enable: true
devWorkspace:
# Deploys the DevWorkspace Operator in the cluster.
Expand Down
8 changes: 5 additions & 3 deletions deploy/crds/org_v1_che_crd-v1beta1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,10 @@ spec:
description: Deprecated in favor of `externalDevfileRegistries`
fields.
type: string
disableInternalClusterSVCNames:
description: Disable internal cluster SVC names usage to communicate
between components to speed up the traffic and avoid proxy issues.
type: boolean
externalDevfileRegistries:
description: External devfile registries, that serves sample, ready-to-use
devfiles. Configure this in addition to a dedicated devfile registry
Expand Down Expand Up @@ -909,9 +913,7 @@ spec:
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`.
description: Deprecated in favor of `disableInternalClusterSVCNames`.
type: boolean
workspaceNamespaceDefault:
description: Defines Kubernetes default namespace in which user's
Expand Down
8 changes: 5 additions & 3 deletions deploy/crds/org_v1_che_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,10 @@ spec:
description: Deprecated in favor of `externalDevfileRegistries`
fields.
type: string
disableInternalClusterSVCNames:
description: Disable internal cluster SVC names usage to communicate
between components to speed up the traffic and avoid proxy issues.
type: boolean
externalDevfileRegistries:
description: External devfile registries, that serves sample,
ready-to-use devfiles. Configure this in addition to a dedicated
Expand Down Expand Up @@ -926,9 +930,7 @@ spec:
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`.
description: Deprecated in favor of `disableInternalClusterSVCNames`.
type: boolean
workspaceNamespaceDefault:
description: Defines Kubernetes default namespace in which user's
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ metadata:
"serverExposureStrategy": "",
"serverTrustStoreConfigMapName": "",
"tlsSupport": true,
"useInternalClusterSVCNames": true,
"workspaceNamespaceDefault": "<username>-che"
},
"storage": {
Expand All @@ -86,13 +85,13 @@ metadata:
categories: Developer Tools
certified: "false"
containerImage: quay.io/eclipse/che-operator:next
createdAt: "2021-07-07T09:30:36Z"
createdAt: "2021-07-13T06:53:00Z"
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/che-operator
support: Eclipse Foundation
name: eclipse-che-preview-kubernetes.v7.33.0-250.nightly
name: eclipse-che-preview-kubernetes.v7.33.0-252.nightly
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -1241,4 +1240,4 @@ spec:
maturity: stable
provider:
name: Eclipse Foundation
version: 7.33.0-250.nightly
version: 7.33.0-252.nightly
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,10 @@ spec:
description: Deprecated in favor of `externalDevfileRegistries`
fields.
type: string
disableInternalClusterSVCNames:
description: Disable internal cluster SVC names usage to communicate
between components to speed up the traffic and avoid proxy issues.
type: boolean
externalDevfileRegistries:
description: External devfile registries, that serves sample,
ready-to-use devfiles. Configure this in addition to a dedicated
Expand Down Expand Up @@ -926,9 +930,7 @@ spec:
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`.
description: Deprecated in favor of `disableInternalClusterSVCNames`.
type: boolean
workspaceNamespaceDefault:
description: Defines Kubernetes default namespace in which user's
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ metadata:
"serverExposureStrategy": "",
"serverTrustStoreConfigMapName": "",
"tlsSupport": true,
"useInternalClusterSVCNames": true,
"workspaceNamespaceDefault": "<username>-che"
},
"storage": {
Expand All @@ -77,13 +76,13 @@ metadata:
categories: Developer Tools, OpenShift Optional
certified: "false"
containerImage: quay.io/eclipse/che-operator:next
createdAt: "2021-07-07T09:30:48Z"
createdAt: "2021-07-13T06:53:08Z"
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/che-operator
support: Eclipse Foundation
name: eclipse-che-preview-openshift.v7.33.0-250.nightly
name: eclipse-che-preview-openshift.v7.33.0-252.nightly
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -1318,4 +1317,4 @@ spec:
maturity: stable
provider:
name: Eclipse Foundation
version: 7.33.0-250.nightly
version: 7.33.0-252.nightly
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,11 @@ spec:
description: Deprecated in favor of `externalDevfileRegistries`
fields.
type: string
disableInternalClusterSVCNames:
description: Disable internal cluster SVC names usage to communicate
between components to speed up the traffic and avoid proxy
issues.
type: boolean
externalDevfileRegistries:
description: External devfile registries, that serves sample,
ready-to-use devfiles. Configure this in addition to a dedicated
Expand Down Expand Up @@ -941,9 +946,7 @@ spec:
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`.
description: Deprecated in favor of `disableInternalClusterSVCNames`.
type: boolean
workspaceNamespaceDefault:
description: Defines Kubernetes default namespace in which user's
Expand Down
10 changes: 8 additions & 2 deletions pkg/apis/org/v1/che_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,12 @@ type CheClusterSpecServer struct {
// Deprecated. Instructs the Operator to deploy Che in TLS mode. This is enabled by default. Disabling TLS sometimes cause malfunction of some Che components.
// +optional
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`.
// Deprecated in favor of `disableInternalClusterSVCNames`.
// +optional
UseInternalClusterSVCNames bool `json:"useInternalClusterSVCNames"`
// Disable internal cluster SVC names usage to communicate between components to speed up the traffic and avoid proxy issues.
// +optional
DisableInternalClusterSVCNames *bool `json:"disableInternalClusterSVCNames"`
// Overrides the container image used in the dashboard deployment.
// This includes the image tag. Omit it or leave it empty to use the default container image provided by the Operator.
// +optional
Expand Down Expand Up @@ -748,3 +750,7 @@ func (c *CheCluster) IsAirGapMode() bool {
func (c *CheCluster) IsImagePullerSpecEmpty() bool {
return c.Spec.ImagePuller.Spec == (chev1alpha1.KubernetesImagePullerSpec{})
}

func (c *CheCluster) IsInternalClusterSVCNamesEnabled() bool {
return c.Spec.Server.DisableInternalClusterSVCNames == nil || !*c.Spec.Server.DisableInternalClusterSVCNames
}
5 changes: 5 additions & 0 deletions pkg/apis/org/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/controller/che/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (r *ReconcileChe) getProxyConfiguration(deployContext *deploy.DeployContext
if err != nil {
return nil, err
}
if deployContext.CheCluster.Spec.Server.UseInternalClusterSVCNames {
if deployContext.CheCluster.IsInternalClusterSVCNamesEnabled() {
cheClusterProxyConf.NoProxy = deploy.MergeNonProxy(cheClusterProxyConf.NoProxy, ".svc")
}
return cheClusterProxyConf, nil
Expand Down
15 changes: 8 additions & 7 deletions pkg/controller/che/proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
fakeDiscovery "k8s.io/client-go/discovery/fake"
fakeclientset "k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/utils/pointer"
"sigs.k8s.io/controller-runtime/pkg/client/fake"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
Expand Down Expand Up @@ -249,9 +250,10 @@ func TestReadProxyConfiguration(t *testing.T) {
},
Spec: orgv1.CheClusterSpec{
Server: orgv1.CheClusterSpecServer{
ProxyURL: "http://proxy",
ProxyPort: "3128",
NonProxyHosts: "host1",
DisableInternalClusterSVCNames: pointer.BoolPtr(true),
ProxyURL: "http://proxy",
ProxyPort: "3128",
NonProxyHosts: "host1",
},
},
},
Expand Down Expand Up @@ -281,10 +283,9 @@ func TestReadProxyConfiguration(t *testing.T) {
},
Spec: orgv1.CheClusterSpec{
Server: orgv1.CheClusterSpecServer{
ProxyURL: "http://proxy",
ProxyPort: "3128",
NonProxyHosts: "host1",
UseInternalClusterSVCNames: true,
ProxyURL: "http://proxy",
ProxyPort: "3128",
NonProxyHosts: "host1",
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/deploy/identity-provider/deployment_keycloak.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ func GetSpecKeycloakDeployment(
}

var enableFixedHostNameProvider string
if deployContext.CheCluster.Spec.Server.UseInternalClusterSVCNames {
if deployContext.CheCluster.IsInternalClusterSVCNamesEnabled() {
if cheFlavor == "che" {
keycloakURL, err := url.Parse(deployContext.CheCluster.Status.KeycloakURL)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/deploy/server/server_configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,28 +189,28 @@ func (s *Server) getCheConfigMapData() (cheEnv map[string]string, err error) {
cheAPI := protocol + "://" + cheHost + "/api"
var keycloakInternalURL, pluginRegistryInternalURL, devfileRegistryInternalURL, cheInternalAPI, webSocketEndpoint, webSocketEndpointMinor string

if s.deployContext.CheCluster.Spec.Server.UseInternalClusterSVCNames && !s.deployContext.CheCluster.Spec.Auth.ExternalIdentityProvider {
if s.deployContext.CheCluster.IsInternalClusterSVCNamesEnabled() && !s.deployContext.CheCluster.Spec.Auth.ExternalIdentityProvider {
keycloakInternalURL = fmt.Sprintf("%s://%s.%s.svc:8080/auth", "http", deploy.IdentityProviderName, s.deployContext.CheCluster.Namespace)
} else {
keycloakInternalURL = keycloakURL
}

// If there is a devfile registry deployed by operator
if !s.deployContext.CheCluster.Spec.Server.ExternalDevfileRegistry {
if s.deployContext.CheCluster.Spec.Server.UseInternalClusterSVCNames {
if s.deployContext.CheCluster.IsInternalClusterSVCNamesEnabled() {
devfileRegistryInternalURL = fmt.Sprintf("http://%s.%s.svc:8080", deploy.DevfileRegistryName, s.deployContext.CheCluster.Namespace)
} else {
devfileRegistryInternalURL = s.deployContext.CheCluster.Status.DevfileRegistryURL
}
}

if s.deployContext.CheCluster.Spec.Server.UseInternalClusterSVCNames && !s.deployContext.CheCluster.Spec.Server.ExternalPluginRegistry {
if s.deployContext.CheCluster.IsInternalClusterSVCNamesEnabled() && !s.deployContext.CheCluster.Spec.Server.ExternalPluginRegistry {
pluginRegistryInternalURL = fmt.Sprintf("http://%s.%s.svc:8080/v3", deploy.PluginRegistryName, s.deployContext.CheCluster.Namespace)
} else {
pluginRegistryInternalURL = pluginRegistryURL
}

if s.deployContext.CheCluster.Spec.Server.UseInternalClusterSVCNames {
if s.deployContext.CheCluster.IsInternalClusterSVCNamesEnabled() {
cheInternalAPI = fmt.Sprintf("http://%s.%s.svc:8080/api", deploy.CheServiceName, s.deployContext.CheCluster.Namespace)
webSocketEndpoint = fmt.Sprintf("ws://%s.%s.svc:8080/api/websocket", deploy.CheServiceName, s.deployContext.CheCluster.Namespace)
webSocketEndpointMinor = fmt.Sprintf("ws://%s.%s.svc:8080/api/websocket-minor", deploy.CheServiceName, s.deployContext.CheCluster.Namespace)
Expand Down
Loading

0 comments on commit f67a5ce

Please sign in to comment.