From 2b7ebd8f852c154f8ab5d423130ea8cbb64ce223 Mon Sep 17 00:00:00 2001 From: Sergii Kabashniuk Date: Thu, 30 Aug 2018 10:18:51 +0300 Subject: [PATCH] Added ability to deploy che plugin registry with ocp.sh (#10954) Added ability to deploy che plugin registry with ocp.sh ./ocp.sh --deploy-che --deploy-che-plugin-registry Add environment variableCHE_PLUGIN_REGISTRY_URL for che-master with a link to che plugin registry --- deploy/openshift/deploy_che.sh | 32 ++++++ deploy/openshift/ocp.sh | 6 ++ .../templates/che-plugin-registry.yml | 100 ++++++++++++++++++ .../templates/che-server-template.yaml | 8 +- 4 files changed, 144 insertions(+), 2 deletions(-) create mode 100644 deploy/openshift/templates/che-plugin-registry.yml diff --git a/deploy/openshift/deploy_che.sh b/deploy/openshift/deploy_che.sh index 722ecdb964..7c8bd003e9 100755 --- a/deploy/openshift/deploy_che.sh +++ b/deploy/openshift/deploy_che.sh @@ -144,6 +144,18 @@ export ${KEYCLOAK_IMAGE_PULL_POLICY:-${DEFAULT_KEYCLOAK_IMAGE_PULL_POLICY}} DEFAULT_ENABLE_SSL="false" export ENABLE_SSL=${ENABLE_SSL:-${DEFAULT_ENABLE_SSL}} +DEFAULT_PLUGIN_REGISTRY_IMAGE_TAG="latest" +export PLUGIN_REGISTRY_IMAGE_TAG=${PLUGIN_REGISTRY_IMAGE_TAG:-${DEFAULT_PLUGIN_REGISTRY_IMAGE_TAG}} + +DEFAULT_PLUGIN_REGISTRY_IMAGE="eclipse/che-plugin-registry" +export PLUGIN_REGISTRY_IMAGE=${PLUGIN_REGISTRY_IMAGE:-${DEFAULT_PLUGIN_REGISTRY_IMAGE}} + +DEFAULT_PLUGIN_REGISTRY_IMAGE_PULL_POLICY="Always" +export PLUGIN_REGISTRY_IMAGE_PULL_POLICY=${PLUGIN_REGISTRY_IMAGE_PULL_POLICY:-${DEFAULT_PLUGIN_REGISTRY_IMAGE_PULL_POLICY}} + +DEFAULT_PLUGIN_REGISTRY_URL="NULL" +export PLUGIN_REGISTRY_URL=${PLUGIN_REGISTRY_URL:-${DEFAULT_PLUGIN_REGISTRY_URL}} + if [ "${ENABLE_SSL}" == "true" ]; then HTTP_PROTOCOL="https" WS_PROTOCOL="wss" @@ -336,6 +348,19 @@ getRoutingSuffix() { fi } +deployChePluginRegistry() { +if [ "${DEPLOY_CHE_PLUGIN_REGISTRY}" == "true" ]; then + echo "Deploying Che plugin registry..." + ${OC_BINARY} new-app -f ${BASE_DIR}/templates/che-plugin-registry.yml \ + -p IMAGE=${PLUGIN_REGISTRY_IMAGE} \ + -p IMAGE_TAG=${PLUGIN_REGISTRY_IMAGE_TAG} \ + -p PULL_POLICY=${PLUGIN_REGISTRY_IMAGE_PULL_POLICY} + + PLUGIN_REGISTRY_ROUTE=$($OC_BINARY get route/che-plugin-registry --namespace=${CHE_OPENSHIFT_PROJECT} -o=jsonpath={'.spec.host'}) + echo "Che plugin registry deployment complete. $PLUGIN_REGISTRY_ROUTE" +fi +} + deployChe() { CHE_VAR_ARRAY=$(env | grep "^CHE_.") @@ -410,6 +435,11 @@ ${CHE_VAR_ARRAY}" fi fi + if [ "${DEPLOY_CHE_PLUGIN_REGISTRY}" == "true" ]; then + PLUGIN_REGISTRY_ROUTE=$($OC_BINARY get route/che-plugin-registry --namespace=${CHE_OPENSHIFT_PROJECT} -o=jsonpath={'.spec.host'}) + PLUGIN_REGISTRY_URL="${HTTP_PROTOCOL}://${PLUGIN_REGISTRY_ROUTE}/plugins/" + fi + ${OC_BINARY} new-app -f ${BASE_DIR}/templates/che-server-template.yaml \ -p ROUTING_SUFFIX=${OPENSHIFT_ROUTING_SUFFIX} \ -p IMAGE_CHE=${CHE_IMAGE_REPO} \ @@ -422,6 +452,7 @@ ${CHE_VAR_ARRAY}" -p CHE_INFRA_OPENSHIFT_PROJECT=${CHE_INFRA_OPENSHIFT_PROJECT} \ -p CHE_INFRA_OPENSHIFT_OAUTH__IDENTITY__PROVIDER=${CHE_INFRA_OPENSHIFT_OAUTH__IDENTITY__PROVIDER} \ -p TLS=${TLS} \ + -p CHE_PLUGIN_REGISTRY_URL=${PLUGIN_REGISTRY_URL} \ ${ENV} if [ ${UPDATE_STRATEGY} == "Recreate" ]; then @@ -447,4 +478,5 @@ ${CHE_VAR_ARRAY}" isLoggedIn createNewProject getRoutingSuffix +deployChePluginRegistry deployChe diff --git a/deploy/openshift/ocp.sh b/deploy/openshift/ocp.sh index 066d06e8b3..1723b55b30 100755 --- a/deploy/openshift/ocp.sh +++ b/deploy/openshift/ocp.sh @@ -89,6 +89,7 @@ export KEYCLOAK_USER=${KEYCLOAK_USER:-${DEFAULT_KEYCLOAK_USER}} DEFAULT_KEYCLOAK_PASSWORD=admin export KEYCLOAK_PASSWORD=${KEYCLOAK_PASSWORD:-${DEFAULT_KEYCLOAK_PASSWORD}} + } test_dns_provider() { @@ -297,6 +298,7 @@ parse_args() { --image-che - override default Che image. Example: --image-che=org/repo:tag. Tag is mandatory! --remove-che - remove existing che project --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 =================================== ENV vars CHE_IMAGE_TAG - set che-server image tag, default: nightly @@ -381,6 +383,10 @@ parse_args() { echo -e "$HELP" exit 1 ;; + --deploy-che-plugin-registry) + export DEPLOY_CHE_PLUGIN_REGISTRY=true + shift + ;; *) echo "You've passed wrong arg '$i'." echo -e "$HELP" diff --git a/deploy/openshift/templates/che-plugin-registry.yml b/deploy/openshift/templates/che-plugin-registry.yml new file mode 100644 index 0000000000..0b3e690dd0 --- /dev/null +++ b/deploy/openshift/templates/che-plugin-registry.yml @@ -0,0 +1,100 @@ +# +# Copyright (c) 2012-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-plugin-registry-service +objects: +- apiVersion: v1 + kind: DeploymentConfig + metadata: + labels: + app: che-plugin-registry + name: che-plugin-registry + spec: + replicas: 1 + selector: + app: che-plugin-registry + deploymentconfig: che-plugin-registry + strategy: + rollingParams: + intervalSeconds: 1 + maxSurge: 25% + maxUnavailable: 25% + timeoutSeconds: 600 + updatePeriodSeconds: 1 + type: Rolling + template: + metadata: + labels: + app: che-plugin-registry + deploymentconfig: che-plugin-registry + spec: + containers: + - image: ${IMAGE}:${IMAGE_TAG} + imagePullPolicy: "${PULL_POLICY}" + name: che-plugin-registry + ports: + - containerPort: 8080 + livenessProbe: + httpGet: + path: /plugins/ + port: 8080 + initialDelaySeconds: 30 + periodSeconds: 10 + timeoutSeconds: 3 + readinessProbe: + httpGet: + path: /plugins/ + port: 8080 + initialDelaySeconds: 3 + periodSeconds: 10 + timeoutSeconds: 3 + resources: + limits: + memory: ${MEMORY_LIMIT} + triggers: + - type: ConfigChange +- apiVersion: v1 + kind: Service + metadata: + name: che-plugin-registry + spec: + ports: + - protocol: TCP + port: 80 + targetPort: 8080 + selector: + deploymentconfig: che-plugin-registry +- apiVersion: v1 + kind: Route + metadata: + name: che-plugin-registry + spec: + to: + kind: Service + name: che-plugin-registry +parameters: +- name: IMAGE + value: eclipse/che-plugin-registry + displayName: Eclipse Che plugin registry image + description: Che plugin registry Docker image. Defaults to eclipse/che-plugin-registry +- name: IMAGE_TAG + value: latest + displayName: Eclipse Che plugin registry version + description: Eclipse Che plugin 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 plugin registry image pull policy + description: Always pull by default. Can be IfNotPresent diff --git a/deploy/openshift/templates/che-server-template.yaml b/deploy/openshift/templates/che-server-template.yaml index 0b04dbc42a..2c9bda7e61 100644 --- a/deploy/openshift/templates/che-server-template.yaml +++ b/deploy/openshift/templates/che-server-template.yaml @@ -145,8 +145,8 @@ objects: key: ca.crt name: openshift-identity-provider optional: true - - name: CHE_WORKSPACE_FEATURE_API - value: "http://che-plugin-registry:80" + - name: CHE_PLUGIN_REGISTRY_URL + value: "${CHE_PLUGIN_REGISTRY_URL}" image: ${IMAGE_CHE}:${CHE_VERSION} imagePullPolicy: "${PULL_POLICY}" livenessProbe: @@ -277,6 +277,10 @@ parameters: displayName: GitHub Client Secret description: GitHub oAuth app client servet. Applicable to Che single user only! value: '' +- name: CHE_PLUGIN_REGISTRY_URL + displayName: Eclipse Che plugin registry URL + description: Url that used to get meta information about Eclipse Che tooling + value: 'NULL' labels: app: che template: che