diff --git a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties index 6b609f08fd..faeb3fb06c 100644 --- a/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties +++ b/assembly/assembly-wsmaster-war/src/main/webapp/WEB-INF/classes/che/che.properties @@ -18,6 +18,9 @@ che.database=${che.home}/storage # API service. Browsers initiate REST communications to Che server with this URL. che.api=http://${CHE_HOST}:${CHE_PORT}/api +# API service internal network url. Back-end services should initiate REST communications to Che server with this URL +che.api.internal=http://${CHE_HOST}:${CHE_PORT}/api + # Che websocket major endpoint. Provides basic communication endpoint # for major websocket interactions and messaging. che.websocket.endpoint=ws://${CHE_HOST}:${CHE_PORT}/api/websocket @@ -551,11 +554,21 @@ che.workspace.plugin_broker.wait_timeout_min=3 # In case Che plugins tooling is not needed value 'NULL' should be used che.workspace.plugin_registry_url=https://che-plugin-registry.prod-preview.openshift.io/v3 +# Workspace tooling plugins registry "internal" endpoint. Should be a valid HTTP URL. +# Example: http://devfile-registry.che.svc.cluster.local:8080 +# In case Che plugins tooling is not needed value 'NULL' should be used +che.workspace.plugin_registry_internal_url=NULL + # Devfile Registry endpoint. Should be a valid HTTP URL. # Example: http://che-devfile-registry-eclipse-che.192.168.65.2.nip.io # In case Che plugins tooling is not needed value 'NULL' should be used che.workspace.devfile_registry_url=https://che-devfile-registry.prod-preview.openshift.io/ +# Devfile Registry "internal" endpoint. Should be a valid HTTP URL. +# Example: http://plugin-registry.che.svc.cluster.local:8080 +# In case Che plugins tooling is not needed value 'NULL' should be used +che.workspace.devfile_registry_internal_url=NULL + # The configuration property that defines available values for storage types that clients like # Dashboard should propose for users during workspace creation/update. # Available values: diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProvider.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProvider.java index 658bba1ec5..9d6177c697 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProvider.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/provision/KubernetesCheApiInternalEnvVarProvider.java @@ -28,7 +28,8 @@ public class KubernetesCheApiInternalEnvVarProvider implements CheApiInternalEnv private final String cheServerEndpoint; @Inject - public KubernetesCheApiInternalEnvVarProvider(@Named("che.api") String cheServerEndpoint) { + public KubernetesCheApiInternalEnvVarProvider( + @Named("che.api.internal") String cheServerEndpoint) { this.cheServerEndpoint = cheServerEndpoint; } diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactory.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactory.java index 9a04664d7e..4d27317f3e 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactory.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactory.java @@ -11,6 +11,7 @@ */ package org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.brokerphases; +import static com.google.common.base.Strings.isNullOrEmpty; import static java.util.Collections.singletonMap; import com.fasterxml.jackson.core.JsonProcessingException; @@ -87,6 +88,7 @@ public abstract class BrokerEnvironmentFactory String artifactsBrokerImage, String metadataBrokerImage, String pluginRegistryUrl, + String pluginRegistryInternalUrl, CertificateProvisioner certProvisioner) { this.cheWebsocketEndpoint = cheWebsocketEndpoint; this.brokerPullPolicy = brokerPullPolicy; @@ -94,7 +96,8 @@ public abstract class BrokerEnvironmentFactory this.machineTokenEnvVarProvider = machineTokenEnvVarProvider; this.artifactsBrokerImage = artifactsBrokerImage; this.metadataBrokerImage = metadataBrokerImage; - this.pluginRegistryUrl = pluginRegistryUrl; + this.pluginRegistryUrl = + isNullOrEmpty(pluginRegistryInternalUrl) ? pluginRegistryUrl : pluginRegistryInternalUrl; this.certProvisioner = certProvisioner; } diff --git a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/KubernetesBrokerEnvironmentFactory.java b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/KubernetesBrokerEnvironmentFactory.java index 2d0b3de518..3c68631ead 100644 --- a/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/KubernetesBrokerEnvironmentFactory.java +++ b/infrastructures/kubernetes/src/main/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/KubernetesBrokerEnvironmentFactory.java @@ -19,7 +19,6 @@ import org.eclipse.che.api.workspace.server.spi.provision.env.MachineTokenEnvVar import org.eclipse.che.commons.annotation.Nullable; import org.eclipse.che.workspace.infrastructure.kubernetes.environment.KubernetesEnvironment; import org.eclipse.che.workspace.infrastructure.kubernetes.provision.CertificateProvisioner; -import org.eclipse.che.workspace.infrastructure.kubernetes.wsplugins.brokerphases.BrokerEnvironmentFactory.BrokersConfigs; /** * Extends {@link BrokerEnvironmentFactory} to be used in the kubernetes infrastructure. @@ -41,6 +40,8 @@ public class KubernetesBrokerEnvironmentFactory @Named("che.workspace.plugin_broker.artifacts.image") String artifactsBrokerImage, @Named("che.workspace.plugin_broker.metadata.image") String metadataBrokerImage, @Nullable @Named("che.workspace.plugin_registry_url") String pluginRegistryUrl, + @Nullable @Named("che.workspace.plugin_registry_internal_url") + String pluginRegistryInternalUrl, CertificateProvisioner certProvisioner) { super( cheWebsocketEndpoint, @@ -50,6 +51,7 @@ public class KubernetesBrokerEnvironmentFactory artifactsBrokerImage, metadataBrokerImage, pluginRegistryUrl, + pluginRegistryInternalUrl, certProvisioner); } diff --git a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java index 8d13ec1325..3bad18fab4 100644 --- a/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java +++ b/infrastructures/kubernetes/src/test/java/org/eclipse/che/workspace/infrastructure/kubernetes/wsplugins/brokerphases/BrokerEnvironmentFactoryTest.java @@ -74,6 +74,7 @@ public class BrokerEnvironmentFactoryTest { ARTIFACTS_BROKER_IMAGE, METADATA_BROKER_IMAGE, DEFAULT_REGISTRY, + "", certProvisioner) { @Override protected KubernetesEnvironment doCreate(BrokersConfigs brokersConfigs) { diff --git a/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/wsplugins/brokerphases/OpenshiftBrokerEnvironmentFactory.java b/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/wsplugins/brokerphases/OpenshiftBrokerEnvironmentFactory.java index 6e8a2cd6f0..c8564897ed 100644 --- a/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/wsplugins/brokerphases/OpenshiftBrokerEnvironmentFactory.java +++ b/infrastructures/openshift/src/main/java/org/eclipse/che/workspace/infrastructure/openshift/wsplugins/brokerphases/OpenshiftBrokerEnvironmentFactory.java @@ -51,6 +51,8 @@ public class OpenshiftBrokerEnvironmentFactory @Named("che.workspace.plugin_broker.artifacts.image") String artifactsBrokerImage, @Named("che.workspace.plugin_broker.metadata.image") String metadataBrokerImage, @Nullable @Named("che.workspace.plugin_registry_url") String pluginRegistryUrl, + @Nullable @Named("che.workspace.plugin_registry_internal_url") + String pluginRegistryInternalUrl, @Named("che.infra.openshift.trusted_ca_bundles_mount_path") String caCertificatesMountPath, CertificateProvisioner certProvisioner, OpenShiftProjectFactory factory, @@ -63,6 +65,7 @@ public class OpenshiftBrokerEnvironmentFactory artifactsBrokerImage, metadataBrokerImage, pluginRegistryUrl, + pluginRegistryInternalUrl, certProvisioner); this.caCertificatesMountPath = caCertificatesMountPath; this.metadataBrokerImage = metadataBrokerImage; diff --git a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java index a2146653db..9fa84f297e 100644 --- a/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java +++ b/wsmaster/che-core-api-workspace-shared/src/main/java/org/eclipse/che/api/workspace/shared/Constants.java @@ -60,10 +60,18 @@ public final class Constants { public static final String CHE_WORKSPACE_PLUGIN_REGISTRY_URL_PROPERTY = "che.workspace.plugin_registry_url"; + /** Property name for internal network Che plugin registry url. */ + public static final String CHE_WORKSPACE_PLUGIN_REGISTRY_INTERNAL_URL_PROPERTY = + "che.workspace.plugin_registry_internal_url"; + /** Property name for Che Devfile Registry URL. */ public static final String CHE_WORKSPACE_DEVFILE_REGISTRY_URL_PROPERTY = "che.workspace.devfile_registry_url"; + /** Property name for internal network Che Devfile Registry URL. */ + public static final String CHE_WORKSPACE_DEVFILE_REGISTRY_INTERNAL_URL_PROPERTY = + "che.workspace.devfile_registry_internal_url"; + /** Name for environment variable of machine name */ public static final String CHE_MACHINE_NAME_ENV_VAR = "CHE_MACHINE_NAME"; /** diff --git a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceService.java b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceService.java index 4e61269bd6..81ac0082ef 100644 --- a/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceService.java +++ b/wsmaster/che-core-api-workspace/src/main/java/org/eclipse/che/api/workspace/server/WorkspaceService.java @@ -19,7 +19,9 @@ import static javax.ws.rs.core.MediaType.APPLICATION_JSON; import static org.eclipse.che.api.workspace.server.DtoConverter.asDto; import static org.eclipse.che.api.workspace.server.WorkspaceKeyValidator.validateKey; import static org.eclipse.che.api.workspace.shared.Constants.CHE_WORKSPACE_AUTO_START; +import static org.eclipse.che.api.workspace.shared.Constants.CHE_WORKSPACE_DEVFILE_REGISTRY_INTERNAL_URL_PROPERTY; import static org.eclipse.che.api.workspace.shared.Constants.CHE_WORKSPACE_DEVFILE_REGISTRY_URL_PROPERTY; +import static org.eclipse.che.api.workspace.shared.Constants.CHE_WORKSPACE_PLUGIN_REGISTRY_INTERNAL_URL_PROPERTY; import static org.eclipse.che.api.workspace.shared.Constants.CHE_WORKSPACE_PLUGIN_REGISTRY_URL_PROPERTY; import static org.eclipse.che.api.workspace.shared.Constants.CHE_WORKSPACE_STORAGE_AVAILABLE_TYPES; import static org.eclipse.che.api.workspace.shared.Constants.CHE_WORKSPACE_STORAGE_PREFERRED_TYPE; @@ -101,7 +103,9 @@ public class WorkspaceService extends Service { private final MachineTokenProvider machineTokenProvider; private final WorkspaceLinksGenerator linksGenerator; private final String pluginRegistryUrl; + private final String pluginRegistryInternalUrl; private final String devfileRegistryUrl; + private final String devfileRegistryInternalUrl; private final String apiEndpoint; private final boolean cheWorkspaceAutoStart; private final FileContentProvider devfileContentProvider; @@ -117,7 +121,11 @@ public class WorkspaceService extends Service { MachineTokenProvider machineTokenProvider, WorkspaceLinksGenerator linksGenerator, @Named(CHE_WORKSPACE_PLUGIN_REGISTRY_URL_PROPERTY) @Nullable String pluginRegistryUrl, + @Named(CHE_WORKSPACE_PLUGIN_REGISTRY_INTERNAL_URL_PROPERTY) @Nullable + String pluginRegistryInternalUrl, @Named(CHE_WORKSPACE_DEVFILE_REGISTRY_URL_PROPERTY) @Nullable String devfileRegistryUrl, + @Named(CHE_WORKSPACE_DEVFILE_REGISTRY_INTERNAL_URL_PROPERTY) @Nullable + String devfileRegistryInternalUrl, URLFetcher urlFetcher, @Named(DEBUG_WORKSPACE_START_LOG_LIMIT_BYTES) Long logLimitBytes, @Named(CHE_WORKSPACE_STORAGE_AVAILABLE_TYPES) String availableStorageTypes, @@ -127,8 +135,10 @@ public class WorkspaceService extends Service { this.workspaceManager = workspaceManager; this.machineTokenProvider = machineTokenProvider; this.linksGenerator = linksGenerator; + this.pluginRegistryInternalUrl = pluginRegistryInternalUrl; this.pluginRegistryUrl = pluginRegistryUrl; this.devfileRegistryUrl = devfileRegistryUrl; + this.devfileRegistryInternalUrl = devfileRegistryInternalUrl; this.devfileContentProvider = new URLFileContentProvider(null, urlFetcher); this.logLimitBytes = logLimitBytes; this.availableStorageTypes = availableStorageTypes; @@ -430,9 +440,18 @@ public class WorkspaceService extends Service { settings.put("cheWorkspacePluginRegistryUrl", pluginRegistryUrl); } + if (pluginRegistryInternalUrl != null) { + settings.put("cheWorkspacePluginRegistryInternalUrl", pluginRegistryInternalUrl); + } + if (devfileRegistryUrl != null) { settings.put("cheWorkspaceDevfileRegistryUrl", devfileRegistryUrl); } + + if (devfileRegistryInternalUrl != null) { + settings.put("cheWorkspaceDevfileRegistryInternalUrl", devfileRegistryInternalUrl); + } + settings.put(CHE_WORKSPACE_STORAGE_AVAILABLE_TYPES, availableStorageTypes); settings.put(CHE_WORKSPACE_STORAGE_PREFERRED_TYPE, preferredStorageType); return settings.build(); diff --git a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTest.java b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTest.java index 95d8ad2913..d9ee1d1b07 100644 --- a/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTest.java +++ b/wsmaster/che-core-api-workspace/src/test/java/org/eclipse/che/api/workspace/server/WorkspaceServiceTest.java @@ -128,8 +128,12 @@ public class WorkspaceServiceTest { private static final String USER_ID = "user123"; private static final String API_ENDPOINT = "http://localhost:8080/api"; private static final String CHE_WORKSPACE_PLUGIN_REGISTRY_URL = "http://localhost:9898/plugins/"; + private static final String CHE_WORKSPACE_PLUGIN_REGISTRY_INTERNAL_URL = + "http://plugin-registry.che.svc.cluster.local/v3"; private static final String CHE_WORKSPACE_DEVFILE_REGISTRY_URL = "http://localhost:9898/devfiles/"; + private static final String CHE_WORKSPACE_DEVFILE_REGISTRY_INTERNAL_URL = + "http://plugin-registry.che.svc.cluster.local"; private static final boolean CHE_WORKSPACES_DEFAULT_PERSIST_VOLUMES = false; private static final Long LOG_LIMIT_BYTES = 64L; @@ -168,7 +172,9 @@ public class WorkspaceServiceTest { machineTokenProvider, linksGenerator, CHE_WORKSPACE_PLUGIN_REGISTRY_URL, + CHE_WORKSPACE_PLUGIN_REGISTRY_INTERNAL_URL, CHE_WORKSPACE_DEVFILE_REGISTRY_URL, + CHE_WORKSPACE_DEVFILE_REGISTRY_INTERNAL_URL, urlFetcher, LOG_LIMIT_BYTES, availableStorageTypes, @@ -884,7 +890,12 @@ public class WorkspaceServiceTest { .put(SUPPORTED_RECIPE_TYPES, "dockerimage,dockerfile") .put(CHE_WORKSPACE_AUTO_START, "true") .put("cheWorkspacePluginRegistryUrl", CHE_WORKSPACE_PLUGIN_REGISTRY_URL) + .put( + "cheWorkspacePluginRegistryInternalUrl", CHE_WORKSPACE_PLUGIN_REGISTRY_INTERNAL_URL) .put("cheWorkspaceDevfileRegistryUrl", CHE_WORKSPACE_DEVFILE_REGISTRY_URL) + .put( + "cheWorkspaceDevfileRegistryInternalUrl", + CHE_WORKSPACE_DEVFILE_REGISTRY_INTERNAL_URL) .put(CHE_WORKSPACE_STORAGE_AVAILABLE_TYPES, availableStorageTypes) .put(CHE_WORKSPACE_STORAGE_PREFERRED_TYPE, preferredStorageType) .build());