Use internal network url for plugin, devfile registry and fix CHE_API_INTERNAL env. (#17945)
* Use internal network url for plugin, devfile registry and fix CHE_API_INTERNAL env. Signed-off-by: Oleksandr Andriienko <oandriie@redhat.com>7.24.x
parent
c366ed6a88
commit
b562d092c6
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<E extends KubernetesEnvironment>
|
|||
String artifactsBrokerImage,
|
||||
String metadataBrokerImage,
|
||||
String pluginRegistryUrl,
|
||||
String pluginRegistryInternalUrl,
|
||||
CertificateProvisioner certProvisioner) {
|
||||
this.cheWebsocketEndpoint = cheWebsocketEndpoint;
|
||||
this.brokerPullPolicy = brokerPullPolicy;
|
||||
|
|
@ -94,7 +96,8 @@ public abstract class BrokerEnvironmentFactory<E extends KubernetesEnvironment>
|
|||
this.machineTokenEnvVarProvider = machineTokenEnvVarProvider;
|
||||
this.artifactsBrokerImage = artifactsBrokerImage;
|
||||
this.metadataBrokerImage = metadataBrokerImage;
|
||||
this.pluginRegistryUrl = pluginRegistryUrl;
|
||||
this.pluginRegistryUrl =
|
||||
isNullOrEmpty(pluginRegistryInternalUrl) ? pluginRegistryUrl : pluginRegistryInternalUrl;
|
||||
this.certProvisioner = certProvisioner;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,7 @@ public class BrokerEnvironmentFactoryTest {
|
|||
ARTIFACTS_BROKER_IMAGE,
|
||||
METADATA_BROKER_IMAGE,
|
||||
DEFAULT_REGISTRY,
|
||||
"",
|
||||
certProvisioner) {
|
||||
@Override
|
||||
protected KubernetesEnvironment doCreate(BrokersConfigs brokersConfigs) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Reference in New Issue