Skip to content

Commit

Permalink
Integrate Che Server with Devfile Registry
Browse files Browse the repository at this point in the history
Signed-off-by: Sergii Leshchenko <sleshche@redhat.com>
  • Loading branch information
sleshchenko committed May 30, 2019
1 parent 3bc9fe7 commit 195b856
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,11 @@ 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.openshift.io/v3

# 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.openshift.io/

# Configures in which way secure servers will be protected with authentication.
# Suitable values:
# - 'default': no additionally authentication system will be enabled.
Expand Down
44 changes: 44 additions & 0 deletions deploy/openshift/deploy_che.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ HELP="
--secure | -s - Deploy Che with SSL enabled
--setup-ocp-oauth - register OCP oauth client and setup Keycloak and Che to use OpenShift Identity Provider
--deploy-che-plugin-registry - deploy Che plugin registry
--deploy-che-devfile-registry - deploy Che devfile registry
--tracing - Deploy jaeger and enable tracing collection
--monitoring - Deploy Grafana + Prometheus and enable metrics collection
===================================
Expand Down Expand Up @@ -123,6 +124,10 @@ case $key in
DEPLOY_CHE_PLUGIN_REGISTRY=true
shift
;;
--deploy-che-devfile-registry)
DEPLOY_CHE_DEVFILE_REGISTRY=true
shift
;;
--help)
echo -e "$HELP"
exit 1
Expand Down Expand Up @@ -195,6 +200,9 @@ export KEYCLOAK_USER=${KEYCLOAK_USER:-${DEFAULT_KEYCLOAK_USER}}
DEFAULT_KEYCLOAK_PASSWORD=admin
export KEYCLOAK_PASSWORD=${KEYCLOAK_PASSWORD:-${DEFAULT_KEYCLOAK_PASSWORD}}

###
### Plugin Registry settings
###
DEFAULT_PLUGIN_REGISTRY_IMAGE_TAG="latest"
export PLUGIN_REGISTRY_IMAGE_TAG=${PLUGIN_REGISTRY_IMAGE_TAG:-${DEFAULT_PLUGIN_REGISTRY_IMAGE_TAG}}

Expand All @@ -207,6 +215,22 @@ export PLUGIN_REGISTRY_IMAGE_PULL_POLICY=${PLUGIN_REGISTRY_IMAGE_PULL_POLICY:-${
DEFAULT_PLUGIN__REGISTRY__URL="https://che-plugin-registry.openshift.io/v3"
export PLUGIN__REGISTRY__URL=${PLUGIN__REGISTRY__URL:-${DEFAULT_PLUGIN__REGISTRY__URL}}

###
### Devfile Registry settings
###
DEFAULT_DEVFILE_REGISTRY_IMAGE_TAG="latest"
export DEVFILE_REGISTRY_IMAGE_TAG=${DEVFILE_REGISTRY_IMAGE_TAG:-${DEFAULT_DEVFILE_REGISTRY_IMAGE_TAG}}

DEFAULT_DEVFILE_REGISTRY_IMAGE="quay.io/openshiftio/che-devfile-registry"
export DEVFILE_REGISTRY_IMAGE=${DEVFILE_REGISTRY_IMAGE:-${DEFAULT_DEVFILE_REGISTRY_IMAGE}}

DEFAULT_DEVFILE_REGISTRY_IMAGE_PULL_POLICY="Always"
export DEVFILE_REGISTRY_IMAGE_PULL_POLICY=${DEVFILE_REGISTRY_IMAGE_PULL_POLICY:-${DEFAULT_DEVFILE_REGISTRY_IMAGE_PULL_POLICY}}

DEFAULT_DEVFILE__REGISTRY__URL="NULL"
export DEVFILE__REGISTRY__URL=${DEVFILE__REGISTRY__URL:-${DEFAULT_DEVFILE__REGISTRY__URL}}


DEFAULT_CHE_METRICS_ENABLED="false"
export CHE_METRICS_ENABLED=${CHE_METRICS_ENABLED:-${DEFAULT_CHE_METRICS_ENABLED}}

Expand Down Expand Up @@ -449,6 +473,19 @@ if [ "${DEPLOY_CHE_PLUGIN_REGISTRY}" == "true" ]; then
fi
}

deployCheDevfileRegistry() {
if [ "${DEPLOY_CHE_DEVFILE_REGISTRY}" == "true" ]; then
echo "Deploying Che devfile registry..."
${OC_BINARY} new-app -f ${BASE_DIR}/templates/che-devfile-registry.yml \
-p IMAGE=${DEVFILE_REGISTRY_IMAGE} \
-p IMAGE_TAG=${DEVFILE_REGISTRY_IMAGE_TAG} \
-p PULL_POLICY=${DEVFILE_REGISTRY_IMAGE_PULL_POLICY}

DEVFILE_REGISTRY_ROUTE=$($OC_BINARY get route/che-devfile-registry --namespace=${CHE_OPENSHIFT_PROJECT} -o=jsonpath={'.spec.host'})
echo "Che devfile registry deployment complete. $DEVFILE_REGISTRY_ROUTE"
fi
}

deployJaeger(){
if [ "${CHE_TRACING_ENABLED}" == "true" ]; then
echo "Deploying Jaeger..."
Expand Down Expand Up @@ -566,6 +603,11 @@ ${CHE_VAR_ARRAY}"
PLUGIN__REGISTRY__URL="${HTTP_PROTOCOL}://${PLUGIN_REGISTRY_ROUTE}/v3"
fi

if [ "${DEPLOY_CHE_DEVFILE_REGISTRY}" == "true" ]; then
DEVFILE_REGISTRY_ROUTE=$($OC_BINARY get route/che-devfile-registry --namespace=${CHE_OPENSHIFT_PROJECT} -o=jsonpath={'.spec.host'})
DEVFILE__REGISTRY__URL="${HTTP_PROTOCOL}://${DEVFILE_REGISTRY_ROUTE}/"
fi

if [ ! -z ${CHE_INFRA_OPENSHIFT_PROJECT} ]; then
# create workspace service account in the predefined workspace
${OC_BINARY} new-app -f ${BASE_DIR}/templates/che-workspace-service-account.yaml \
Expand All @@ -587,6 +629,7 @@ ${CHE_VAR_ARRAY}"
-p CHE_INFRA_OPENSHIFT_OAUTH__IDENTITY__PROVIDER=${CHE_INFRA_OPENSHIFT_OAUTH__IDENTITY__PROVIDER} \
-p TLS=${TLS} \
-p CHE_WORKSPACE_PLUGIN__REGISTRY__URL=${PLUGIN__REGISTRY__URL} \
-p CHE_WORKSPACE_DEVFILE__REGISTRY__URL=${DEVFILE__REGISTRY__URL} \
-p CHE_INFRA_KUBERNETES_SERVICE__ACCOUNT__NAME=${WORKSPACE_SERVICE_ACCOUNT_NAME} \
-p CHE_DEBUG_SERVER=${CHE_DEBUG_SERVER} \
-p CHE_TRACING_ENABLED=${CHE_TRACING_ENABLED} \
Expand Down Expand Up @@ -617,6 +660,7 @@ isLoggedIn
createNewProject
getRoutingSuffix
deployChePluginRegistry
deployCheDevfileRegistry
deployJaeger
deployMetrics
deployChe
100 changes: 100 additions & 0 deletions deploy/openshift/templates/che-devfile-registry.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#
# Copyright (c) 2018 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
---
apiVersion: v1
kind: Template
metadata:
name: che-devfile-registry
objects:
- apiVersion: v1
kind: DeploymentConfig
metadata:
labels:
app: che-devfile-registry
name: che-devfile-registry
spec:
replicas: 1
selector:
app: che-devfile-registry
deploymentconfig: che-devfile-registry
strategy:
rollingParams:
intervalSeconds: 1
maxSurge: 25%
maxUnavailable: 25%
timeoutSeconds: 600
updatePeriodSeconds: 1
type: Rolling
template:
metadata:
labels:
app: che-devfile-registry
deploymentconfig: che-devfile-registry
spec:
containers:
- image: ${IMAGE}:${IMAGE_TAG}
imagePullPolicy: "${PULL_POLICY}"
name: che-devfile-registry
ports:
- containerPort: 8080
livenessProbe:
httpGet:
path: /devfiles/
port: 8080
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 3
readinessProbe:
httpGet:
path: /devfiles/
port: 8080
initialDelaySeconds: 3
periodSeconds: 10
timeoutSeconds: 3
resources:
limits:
memory: ${MEMORY_LIMIT}
triggers:
- type: ConfigChange
- apiVersion: v1
kind: Service
metadata:
name: che-devfile-registry
spec:
ports:
- protocol: TCP
port: 80
targetPort: 8080
selector:
deploymentconfig: che-devfile-registry
- apiVersion: v1
kind: Route
metadata:
name: che-devfile-registry
spec:
to:
kind: Service
name: che-devfile-registry
parameters:
- name: IMAGE
value: eclipse/che-devfile-registry
displayName: Eclipse Che devfile registry image
description: Che devfile registry Docker image. Defaults to eclipse/che-devfile-registry
- name: IMAGE_TAG
value: latest
displayName: Eclipse Che devfile registry version
description: Eclipse Che devfile registry version which defaults to latest
- name: MEMORY_LIMIT
value: 256Mi
displayName: Memory Limit
description: Maximum amount of memory the container can use. Defaults 256Mi
- name: PULL_POLICY
value: Always
displayName: Eclipse Che devfile registry image pull policy
description: Always pull by default. Can be IfNotPresent
6 changes: 6 additions & 0 deletions deploy/openshift/templates/che-server-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ objects:
optional: true
- name: CHE_WORKSPACE_PLUGIN__REGISTRY__URL
value: "${CHE_WORKSPACE_PLUGIN__REGISTRY__URL}"
- name: CHE_WORKSPACE_DEVFILE__REGISTRY__URL
value: "${CHE_WORKSPACE_DEVFILE__REGISTRY__URL}"
- name: CHE_TRACING_ENABLED
value: "${CHE_TRACING_ENABLED}"
- name: CHE_METRICS_ENABLED
Expand Down Expand Up @@ -329,6 +331,10 @@ parameters:
displayName: Eclipse Che plugin registry URL
description: Url that used to get meta information about Eclipse Che tooling
value: 'NULL'
- name: CHE_WORKSPACE_DEVFILE__REGISTRY__URL
displayName: Eclipse Che devfile registry URL
description: Url that used to get meta information about predefined devfiles for workspaces
value: 'NULL'
- name: CHE_WORKSPACE_SIDECAR_DEFAULT__MEMORY__LIMIT__MB
displayName: Plugin sidecar default memory limit
description: Plugin sidecar default memory limit in megabytes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ public final class Constants {

public static final String CHE_WORKSPACE_AUTO_START = "che.workspace.auto_start";

/**
* Property name for Che plugin registry url. Key name of api workspace/settings method results.
*/
/** Property name for Che plugin registry url. */
public static final String CHE_WORKSPACE_PLUGIN_REGISTRY_URL_PROPERTY =
"che.workspace.plugin_registry_url";

/** Property name for Che Devfile Registry URL. */
public static final String CHE_WORKSPACE_DEVFILE_REGISTRY_URL_PROPERTY =
"che.workspace.devfile_registry_url";

/** Name for environment variable of machine name */
public static final String CHE_MACHINE_NAME_ENV_VAR = "CHE_MACHINE_NAME";
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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_URL_PROPERTY;
import static org.eclipse.che.api.workspace.shared.Constants.CHE_WORKSPACE_PLUGIN_REGISTRY_URL_PROPERTY;

import com.google.common.annotations.Beta;
Expand Down Expand Up @@ -96,6 +97,7 @@ public class WorkspaceService extends Service {
private final MachineTokenProvider machineTokenProvider;
private final WorkspaceLinksGenerator linksGenerator;
private final String pluginRegistryUrl;
private final String devfileRegistryUrl;
private final String apiEndpoint;
private final boolean cheWorkspaceAutoStart;

Expand All @@ -106,13 +108,15 @@ public WorkspaceService(
WorkspaceManager workspaceManager,
MachineTokenProvider machineTokenProvider,
WorkspaceLinksGenerator linksGenerator,
@Named(CHE_WORKSPACE_PLUGIN_REGISTRY_URL_PROPERTY) @Nullable String pluginRegistryUrl) {
@Named(CHE_WORKSPACE_PLUGIN_REGISTRY_URL_PROPERTY) @Nullable String pluginRegistryUrl,
@Named(CHE_WORKSPACE_DEVFILE_REGISTRY_URL_PROPERTY) @Nullable String devfileRegistryUrl) {
this.apiEndpoint = apiEndpoint;
this.cheWorkspaceAutoStart = cheWorkspaceAutoStart;
this.workspaceManager = workspaceManager;
this.machineTokenProvider = machineTokenProvider;
this.linksGenerator = linksGenerator;
this.pluginRegistryUrl = pluginRegistryUrl;
this.devfileRegistryUrl = devfileRegistryUrl;
}

@POST
Expand Down Expand Up @@ -796,6 +800,10 @@ public Map<String, String> getSettings() {
settings.put("cheWorkspacePluginRegistryUrl", pluginRegistryUrl);
}

if (devfileRegistryUrl != null) {
settings.put("cheDevfileRegistryUrl", devfileRegistryUrl);
}

return settings.build();
}

Expand Down

0 comments on commit 195b856

Please sign in to comment.