diff --git a/README.md b/README.md index 3e282bb..ad0bbdf 100644 --- a/README.md +++ b/README.md @@ -1 +1,75 @@ -# gravitee-openshift +# gravitee-OpenShift + +## Description + +Gravitee is composed by the following three components: +- gateway +- management-api +- management-ui + +and the following dependecies: +- mongoDB +- elasticsearch limited to version: + - 2.x + - 5.x + +### elastisearch: + * 9200 => REST request + * 9300 => HTTP request + +## gateway +Import the images on openshift registry: + - `docker.io/graviteeio/gateway:latest` + - `oc import-image graviteeio/gateway:latest --confirm` + +before proceed to create all the openshift objects it sets the properties by ENV section of Deployment Config on Openshift template: "" + +``` +- name: GRAVITEE_MANAGEMENT_MONGODB_URI + value: "mongodb://mongodb:27017/gravitee?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&socketTimeoutMS=5000" +- name: GRAVITEE_RATELIMIT_MONGODB_URI + value: "mongodb://mongodb:27017/gravitee?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&socketTimeoutMS=5000" +- name: GRAVITEE_REPORTERS_ELASTICSEARCH_ENDPOINTS_0 + value: "http://elasticsearch:9200" +- name: GRAVITEE_PLUGINS_PATH_0 + value: "$${gravitee.home}/plugins" +# - name: GRAVITEE_PLUGINS_PATH_1 +# value: "$${gravitee.home}/plugins-ext" +``` + +## management-api + - `docker.io/graviteeio/gateway:latest` + - `oc import-image graviteeio/gateway:latest --confirm` + +``` + - name: GRAVITEE_MANAGEMENT_MONGODB_URI + value: "mongodb://mongodb:27017/gravitee?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&socketTimeoutMS=5000" + - name: GRAVITEE_RATELIMIT_MONGODB_URI + value: "mongodb://mongodb:27017/gravitee?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&socketTimeoutMS=5000" + - name: GRAVITEE_ANALYTICS_ELASTICSEARCH_ENDPOINTS_0 + value: "http://elasticsearch:9200" + - name: GRAVITEE_USER_LOGIN_DEFAULTAPPLICATION + value: "false" + - name: GRAVITEE_PLUGINS_PATH_0 + value: "$${gravitee.home}/plugins" +# - name: GRAVITEE_PLUGINS_PATH_1 +# value: $${gravitee.home}/plugins-ext +``` + +## Web Interface for Gravitee + +http://managementui-gravitee.10.5.18.122.nip.io/#!/ +admin/admin + +remember to update the url `10.5.18.122.nip.io` to reach from outside the cluster on the following files: + * images/management-ui/html/constants.json + * images/management-ui/Dockerfile + +# Setup on OpenShift + + * the script: `openshift/create_all.sh` creates all objects + * the script: `openshift/template-graviteeapim.yaml` as openshift system:admin user is automatically used to create all needed openshift objects + +#### issue to fix: + - oc tag images... + - extract in ENV the version of packages (java, nginx, others) diff --git a/images/gateway/Dockerfile b/images/gateway/Dockerfile index 12df1e9..da0683b 100644 --- a/images/gateway/Dockerfile +++ b/images/gateway/Dockerfile @@ -11,26 +11,35 @@ # limitations under the License. #------------------------------------------------------------------------------- FROM graviteeio/java:8 -MAINTAINER Gravitee Team ARG GRAVITEEIO_VERSION=0 -# Update to get support for Zip/Unzip, nc and wget -RUN apk add --update zip unzip netcat-openbsd wget +LABEL name="gateway:${GRAVITEEIO_VERSION}" \ + authors="Gravitee Team " -RUN wget https://download.gravitee.io/graviteeio-apim/distributions/graviteeio-full-${GRAVITEEIO_VERSION}.zip --no-check-certificate -P /tmp/ \ - && unzip /tmp/graviteeio-full-${GRAVITEEIO_VERSION}.zip -d /tmp/ \ - && mv /tmp/graviteeio-full-${GRAVITEEIO_VERSION}/graviteeio-gateway* /opt/graviteeio-gateway \ - && rm -rf /tmp/* +ENV GRAVITEEIO_MONGODB_HOST="localhost" \ + GRAVITEEIO_MONGODB_PORT="27017" \ + GRAVITEEIO_ELASTIC_HOST="localhost" \ + GRAVITEEIO_ELASTIC_PORT="9300" \ + GRAVITEEIO_HOME="/opt/graviteeio-gateway" + +RUN set -eux; \ + echo "===> Installing OS Utility"; \ + apk add --update zip unzip netcat-openbsd wget + +RUN set -eux; \ + echo "===> Installing Gravitee ${GRAVITEEIO_VERSION}"; \ + wget -v https://download.gravitee.io/graviteeio-apim/distributions/graviteeio-full-${GRAVITEEIO_VERSION}.zip --no-check-certificate -P /tmp/; \ + unzip /tmp/graviteeio-full-${GRAVITEEIO_VERSION}.zip -d /tmp/; \ + mv /tmp/graviteeio-full-${GRAVITEEIO_VERSION}/graviteeio-gateway* ${GRAVITEEIO_HOME}; \ + rm -rf /tmp/*; \ + chown -R 1001:0 ${GRAVITEEIO_HOME}; \ + chmod -R ug+rwX ${GRAVITEEIO_HOME} -ENV GRAVITEEIO_HOME /opt/graviteeio-gateway WORKDIR ${GRAVITEEIO_HOME} -ENV GRAVITEEIO_MONGODB_HOST localhost -ENV GRAVITEEIO_MONGODB_PORT 27017 -ENV GRAVITEEIO_ELASTIC_HOST localhost -ENV GRAVITEEIO_ELASTIC_PORT 9300 +COPY config/gravitee.yml ${GRAVITEEIO_HOME}/config/ EXPOSE 8082 -VOLUME ["/opt/graviteeio-gateway/logs"] +VOLUME ["${GRAVITEEIO_HOME}/logs"] CMD ["./bin/gravitee"] diff --git a/images/gateway/Dockerfile-nightly b/images/gateway/Dockerfile-nightly index ff6c895..4632bca 100644 --- a/images/gateway/Dockerfile-nightly +++ b/images/gateway/Dockerfile-nightly @@ -26,6 +26,8 @@ ENV GRAVITEEIO_HOME /opt/graviteeio-gateway-${GRAVITEEIO_VERSION} RUN ln -s ${GRAVITEEIO_HOME} /opt/graviteeio-gateway WORKDIR ${GRAVITEEIO_HOME} +COPY config/gravitee.yml ${GRAVITEEIO_HOME}/config/ + ENV GRAVITEEIO_MONGODB_HOST localhost ENV GRAVITEEIO_MONGODB_PORT 27017 ENV GRAVITEEIO_ELASTIC_HOST localhost diff --git a/images/gateway/config/gravitee.yml b/images/gateway/config/gravitee.yml new file mode 100644 index 0000000..8189a75 --- /dev/null +++ b/images/gateway/config/gravitee.yml @@ -0,0 +1,249 @@ +############################################################################################################ +#################################### Gravitee.IO Gateway - Configuration ################################### +############################################################################################################ + +############################################################################################################ +# This file is the general configuration of Gravitee.IO Gateway: +# - Properties (and respective default values) in comment are provided for information. +# - You can reference other property by using ${property.name} syntax +# - gravitee.home property is automatically set-up by launcher and refers to the installation path. Do not override it ! +# +# Please have a look to http://docs.gravitee.io/ for more options and fine-grained granularity +############################################################################################################ + +# Gateway HTTP server +#http: +# port: 8082 +# host: 0.0.0.0 +# idleTimeout: 0 +# tcpKeepAlive: true +# compressionSupported: false +# maxHeaderSize: 8192 +# maxChunkSize: 8192 +# instances: 0 +# requestTimeout: 30000 +# secured: false +# alpn: false +# ssl: +# clientAuth: false +# keystore: +# path: ${gravitee.home}/security/keystore.jks +# password: secret +# truststore: +# path: ${gravitee.home}/security/truststore.jks +# password: secret + +# Plugins repository +#plugins: +# path: +# - ${gravitee.home}/plugins +# - ${gravitee.home}/my-custom-plugins + +# If a plugin is already installed (but with a different version), management node does not start anymore +# failOnDuplicate: true + +# Management repository is used to store global configuration such as APIs, applications, apikeys, ... +# This is the default configuration using MongoDB (single server) +# For more information about MongoDB configuration, please have a look to: +# - http://api.mongodb.org/java/current/com/mongodb/MongoClientOptions.html +management: + type: mongodb + mongodb: + dbname: ${ds.mongodb.dbname} + host: ${ds.mongodb.host} + port: ${ds.mongodb.port} +# username: +# password: +# connectionsPerHost: 0 +# connectTimeout: 500 +# maxWaitTime: 120000 +# socketTimeout: 500 +# socketKeepAlive: false +# maxConnectionLifeTime: 0 +# maxConnectionIdleTime: 0 +# serverSelectionTimeout: 0 +# description: gravitee.io +# heartbeatFrequency: 10000 +# minHeartbeatFrequency: 500 +# heartbeatConnectTimeout: 1000 +# heartbeatSocketTimeout: 20000 +# localThreshold: 15 +# minConnectionsPerHost: 0 +# sslEnabled: false +# threadsAllowedToBlockForConnectionMultiplier: 5 +# cursorFinalizerEnabled: true +# possible values are 1,2,3... (the number of node) or 'majority' +# writeConcern: 1 +# wtimeout: 0 +# journal: true + +# Management repository: single MongoDB using URI +# For more information about MongoDB configuration using URI, please have a look to: +# - http://api.mongodb.org/java/current/com/mongodb/MongoClientURI.html +#management: +# type: mongodb +# mongodb: +# uri: mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]] + +# Management repository: clustered MongoDB +#management: +# type: mongodb +# mongodb: +# servers: +# - host: mongo1 +# port: 27017 +# - host: mongo2 +# port: 27017 +# dbname: ${ds.mongodb.dbname} +# connectTimeout: 500 +# socketTimeout: 250 + +# When defining rate-limiting policy, the gateway has to store data to share with other gateway instances. +# In this example, we are using MongoDB to store counters. +ratelimit: + type: mongodb + mongodb: + uri: mongodb://${ds.mongodb.host}/${ds.mongodb.dbname} + +cache: + type: ehcache + +# Reporters configuration (used to store reporting monitoring data, request metrics, healthchecks and others... +# All reporters are enabled by default. To stop one of them, you have to add the property 'enabled: false' +reporters: + # logging configuration + #logging: + # max_size: -1 # max size per API log content respectively : client-request, client-response, proxy-request and proxy-response in MB (-1 means no limit) + # Elasticsearch reporter + elasticsearch: + enabled: true # Is the reporter enabled or not (default to true) + endpoints: + - http://${ds.elastic.host}:${ds.elastic.port} +# index: gravitee +# index_per_type: true +# bulk: +# actions: 1000 # Number of requests action before flush +# flush_interval: 5 # Flush interval in seconds +# settings: +# number_of_shards: 5 +# number_of_replicas: 1 +# refresh_interval: 5s +# pipeline: +# plugins: +# ingest: geoip, user_agent +# security: +# username: user +# password: secret +# http: +# timeout: 30000 # in milliseconds +# template_mapping: +# path: ${gravitee.home}/config/reporter/elasticsearch/templates +# extended_request_mapping: request.ftl + +# Gateway service configurations. Provided values are default values. +# All services are enabled by default. To stop one of them, you have to add the property 'enabled: false' (See the +# 'local' service for an example). +services: + core: + http: + enabled: true + port: 18082 + host: localhost + authentication: + # authentication type to be used for the core services + # - none : to disable authentication + # - basic : to use basic authentication + # default is "basic" + type: basic + users: + admin: adminadmin + + # Synchronization daemon used to keep the gateway state in sync with the configuration from the management repository + # Be aware that, by disabling it, the gateway will not be sync with the configuration done through management API + # and management UI + sync: + # Synchronization is done each 5 seconds + cron: '*/5 * * * * *' + + # Service used to store and cache api-keys from the management repository to avoid direct repository communication + # while serving requests. + apikeyscache: + delay: 10000 + unit: MILLISECONDS + threads: 3 # Threads core size used to retrieve api-keys from repository. + + # Local registry service. + # This registry is used to load API Definition with json format from the file system. By doing so, you do not need + # to configure your API using the web console or the rest API (but you need to know and understand the json descriptor + # format to make it work....) + local: + enabled: false + path: ${gravitee.home}/apis # The path to API descriptors + + # Gateway monitoring service. + # This service retrieves metrics like os / process / jvm metrics and send them to an underlying reporting service. + monitoring: + delay: 5000 + unit: MILLISECONDS + + # metrics service + metrics: + enabled: false +# default: local, http_method, http_code +# labels: +# - local +# - remote +# - http_method +# - http_code +# - http_path + prometheus: + enabled: true + + # heartbeat +# heartbeat: +# enabled: true +# delay: 5000 +# unit: MILLISECONDS +# storeSystemProperties: true + +handlers: + request: + transaction: + header: X-Gravitee-Transaction-Id + +# Referenced properties +ds: + mongodb: + dbname: gravitee + host: ${GRAVITEEIO_MONGODB_HOST:localhost} + port: ${GRAVITEEIO_MONGODB_PORT:27017} + elastic: + host: ${GRAVITEEIO_ELASTIC_HOST:localhost} + port: ${GRAVITEEIO_ELASTIC_PORT:9300} + +# Sharding tags configuration +# Allows to define inclusion/exclusion sharding tags to only deploy a part of APIs. To exclude just prefix the tag with '!'. +#tags: products,stocks,!international + +# Multi-tenant configuration +# Allow only a single-value +#tenant: europe + +#policy: +# Customize the api-key header and / or query parameter +# api-key: +# header: X-Gravitee-Api-Key +# param: api-key + +# Gravitee Alert Engine is only available with support +alerts: + enabled: false + default: + enabled: false + # must be reachable by other nodes + cluster: + host: localhost + port: 0 + hazelcast: + config: + path: ${gravitee.home}/config/hazelcast.xml diff --git a/images/management-api/Dockerfile b/images/management-api/Dockerfile index 3bb729e..2937e47 100644 --- a/images/management-api/Dockerfile +++ b/images/management-api/Dockerfile @@ -11,32 +11,43 @@ # limitations under the License. #------------------------------------------------------------------------------- FROM graviteeio/java:8 -MAINTAINER Gravitee Team ARG GRAVITEEIO_VERSION=0 -# Update to get support for Zip/Unzip, nc and wget -RUN apk add --update zip unzip netcat-openbsd wget +LABEL name="gateway:${GRAVITEEIO_VERSION}" \ + authors="Gravitee Team " + +ENV GRAVITEEIO_MONGODB_HOST="mongodb" \ + GRAVITEEIO_MONGODB_PORT="27017" \ + GRAVITEEIO_ELASTIC_HOST="elasticsearch" \ + GRAVITEEIO_ELASTIC_PORT="9200" \ + GRAVITEEIO_HOME="/opt/graviteeio-management-api" \ + GRAVITEEIO_PORTAL_URL="http://localhost:80" \ + GIO_MIN_MEM="1g" \ + GIO_MAX_MEM="2g" + +RUN set -eux; \ + echo "===> Installing OS Utility"; \ + apk add --update zip unzip netcat-openbsd wget + +RUN set -eux; \ + echo "===> Installing the Gravitee Management API ${GRAVITEEIO_VERSION}"; \ + wget https://download.gravitee.io/graviteeio-apim/distributions/graviteeio-full-${GRAVITEEIO_VERSION}.zip --no-check-certificate -P /tmp/; \ + unzip /tmp/graviteeio-full-${GRAVITEEIO_VERSION}.zip -d /tmp/; \ + mv /tmp/graviteeio-full-${GRAVITEEIO_VERSION}/graviteeio-management-api* ${GRAVITEEIO_HOME}; \ + rm -rf /tmp/*; \ + chown -R 1001:0 ${GRAVITEEIO_HOME}; \ + chmod -R ug+rwX ${GRAVITEEIO_HOME} -RUN wget https://download.gravitee.io/graviteeio-apim/distributions/graviteeio-full-${GRAVITEEIO_VERSION}.zip --no-check-certificate -P /tmp/ \ - && unzip /tmp/graviteeio-full-${GRAVITEEIO_VERSION}.zip -d /tmp/ \ - && mv /tmp/graviteeio-full-${GRAVITEEIO_VERSION}/graviteeio-management-api* /opt/graviteeio-management-api \ - && rm -rf /tmp/* - -ENV GRAVITEEIO_HOME /opt/graviteeio-management-api WORKDIR ${GRAVITEEIO_HOME} COPY config/gravitee.yml ${GRAVITEEIO_HOME}/config/ +COPY bin/gravitee ${GRAVITEEIO_HOME}/bin/ -ENV GRAVITEEIO_MONGODB_HOST localhost -ENV GRAVITEEIO_MONGODB_PORT 27017 -ENV GRAVITEEIO_ELASTIC_HOST localhost -ENV GRAVITEEIO_ELASTIC_PORT 9300 - -ENV GRAVITEEIO_PORTAL_URL http://localhost:80 -ENV GIO_MIN_MEM 1g -ENV GIO_MAX_MEM 2g +RUN set -eux; \ + chmod ug+x ${GRAVITEEIO_HOME}/bin/gravitee; \ + chown -R 1001:0 ${GRAVITEEIO_HOME}/bin/gravitee EXPOSE 8083 -VOLUME ["/opt/graviteeio-management-api/logs"] +VOLUME ["${GRAVITEEIO_HOME}/logs"] CMD ["./bin/gravitee"] diff --git a/images/management-api/bin/gravitee b/images/management-api/bin/gravitee new file mode 100755 index 0000000..7e669ae --- /dev/null +++ b/images/management-api/bin/gravitee @@ -0,0 +1,169 @@ +#!/bin/sh + +DIRNAME=`dirname $0` +PROGNAME=`basename $0` + +# OS specific support (must be 'true' or 'false'). +cygwin=false; +darwin=false; +linux=false; +case "`uname`" in + CYGWIN*) + cygwin=true + ;; + + Darwin*) + darwin=true + ;; + + Linux) + linux=true + ;; +esac + +# Force IPv4 on Linux systems since IPv6 doesn't work correctly with jdk5 and lower +if [ "$linux" = "true" ]; then + JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true" +fi + +# Searching for configuration +GRAVITEE_OPTS="" +if [ -f "$GRAVITEEIO_HOME/config/gravitee.yml" ] +then + GRAVITEE_OPTS="-Dgravitee.conf=$GRAVITEEIO_HOME/config/gravitee.yml" +fi + +# Setup GRAVITEE_HOME +if [ "x$GRAVITEE_HOME" = "x" ]; then + # get the full path (without any relative bits) + GRAVITEE_HOME=`cd $DIRNAME/..; pwd -P` +fi + +export GRAVITEE_HOME + +# Move to the context home +cd $GRAVITEE_HOME + +export JAVA_OPTS + +# Setup the JVM +if [ "x$JAVA" = "x" ]; then + if [ "x$JAVA_HOME" != "x" ]; then + JAVA="$JAVA_HOME/bin/java" + else + JAVA="java" + fi +fi + +# Setup the classpath +runjar=`find $GRAVITEE_HOME -name "gravitee-management-api-standalone-bootstrap-*.jar"` +if [ ! -f "$runjar" ]; then + die "Missing required file: $runjar" +fi +GRAVITEE_BOOT_CLASSPATH="$runjar" + +if [ "x$GIO_MIN_MEM" = "x" ]; then + GIO_MIN_MEM=1024m +fi +if [ "x$GIO_MAX_MEM" = "x" ]; then + GIO_MAX_MEM=2048m +fi + +# min and max heap sizes should be set to the same value to avoid +# stop-the-world GC pauses during resize +JAVA_OPTS="$JAVA_OPTS -Xms${GIO_MIN_MEM}" +JAVA_OPTS="$JAVA_OPTS -Xmx${GIO_MAX_MEM}" + +# set to headless, just in case +JAVA_OPTS="$JAVA_OPTS -Djava.awt.headless=true" + +# Force the JVM to use IPv4 stack +if [ "x$GIO_USE_IPV4" != "x" ]; then + JAVA_OPTS="$JAVA_OPTS -Djava.net.preferIPv4Stack=true" +fi + +# Causes the JVM to dump its heap on OutOfMemory. +JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError" +# The path to the heap dump location, note directory must exists and have enough +# space for a full heap dump. +#JAVA_OPTS="$JAVA_OPTS -XX:HeapDumpPath=$GRAVITEE_HOME/logs/heapdump.hprof" + +# Disables explicit GC +JAVA_OPTS="$JAVA_OPTS -XX:+DisableExplicitGC" + +# Ensure UTF-8 encoding by default (e.g. filenames) +JAVA_OPTS="$JAVA_OPTS -Dfile.encoding=UTF-8" + +# Convert paths for Java on Windows +if $cygwin; then + GRAVITEE_BOOT_CLASSPATH=$(cygpath -w $GRAVITEE_BOOT_CLASSPATH) + GRAVITEE_HOME=$(cygpath -w $GRAVITEE_HOME) +fi + +# Display our environment +echo "=========================================================================" +echo "" +echo " Gravitee.IO Management Standalone Runtime Bootstrap Environment" +echo "" +echo " GRAVITEE_HOME: $GRAVITEE_HOME" +echo "" +echo " GRAVITEE_OPTS: $GRAVITEE_OPTS" +echo "" +echo " JAVA: $JAVA" +echo "" +echo " JAVA_OPTS: $JAVA_OPTS" +echo "" +echo " CLASSPATH: $GRAVITEE_BOOT_CLASSPATH" +echo "" +echo "=========================================================================" +echo "" + +# Execute the JVM in the foreground +daemon=`echo $* | egrep -- '(^-d |-d$| -d |--daemon$|--daemon )'` +if [ -z "$daemon" ] ; then + exec "$JAVA" $JAVA_OPTS \ + -cp "$GRAVITEE_BOOT_CLASSPATH" \ + -Dgravitee.home=$GRAVITEE_HOME \ + -Dgravitee.ds.elastic.host=elastic \ + -Dgravitee.ds.elastic.port=9000 \ + -Dvertx.disableFileCaching=true \ + -Dvertx.disableFileCPResolving=true \ + -Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory \ + io.gravitee.management.standalone.boostrap.Bootstrap \ + "$@" +else + while [ $# -gt 0 ]; do + case "$1" in + -p=*) + pid_file="${1#*=}" + ;; + esac + shift + done + + if [ -z "$pid_file" ] ; then + pid_file=/var/run/graviteeio-apim-mgmt.pid + fi + + exec "$JAVA" $JAVA_OPTS \ + -cp "$GRAVITEE_BOOT_CLASSPATH" \ + -Dgravitee.home=$GRAVITEE_HOME \ + -Dgravitee.ds.elastic.host=elastic \ + -Dgravitee.ds.elastic.port=9000 \ + -Dvertx.disableFileCaching=true \ + -Dvertx.disableFileCPResolving=true \ + -Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory \ + io.gravitee.management.standalone.boostrap.Bootstrap \ + "$@" <&- & + + retval=$? + pid=$! + + [ $retval -eq 0 ] || exit $retval + if ! ps -p $pid > /dev/null ; then + exit 1 + fi + + echo $pid > $pid_file + exit 0 +fi diff --git a/images/management-api/config/gravitee.yml b/images/management-api/config/gravitee.yml index 91bd8cf..3abaf39 100644 --- a/images/management-api/config/gravitee.yml +++ b/images/management-api/config/gravitee.yml @@ -270,4 +270,4 @@ portalURL: ${GRAVITEEIO_PORTAL_URL:http://portal-url.net} # Allows to create support ticket (default value: false) #support: - #enabled: true \ No newline at end of file + #enabled: true diff --git a/images/management-ui/Dockerfile b/images/management-ui/Dockerfile index 0accf6a..3381883 100644 --- a/images/management-ui/Dockerfile +++ b/images/management-ui/Dockerfile @@ -31,7 +31,7 @@ RUN wget https://download.gravitee.io/graviteeio-apim/distributions/graviteeio-f && rm -rf /tmp/* -ENV MGMT_API_URL http://managementapi-gravitee.minishift.local/management/ +ENV MGMT_API_URL http://managementapi-gravitee.10.5.18.122.nip.io/management/ RUN cp /var/www/html/constants.json /var/www/html/constants.json.template COPY html/constants.json /var/www/html/constants.json diff --git a/images/management-ui/html/constants.json b/images/management-ui/html/constants.json index 15b1863..10b1843 100644 --- a/images/management-ui/html/constants.json +++ b/images/management-ui/html/constants.json @@ -1,5 +1,5 @@ { - "baseURL": "http://managementapi-gravitee.minishift.local/management/", + "baseURL": "http://managementapi-gravitee.10.5.18.122.nip.io/management/", "portalTitle": "Gravitee.io Portal", "managementTitle": "Gravitee.io Management", "devMode": false, @@ -8,7 +8,7 @@ "url": "https://docs.gravitee.io" }, "portal": { - "entrypoint": "http://gateway-gravitee.minishift.local", + "entrypoint": "http://gateway-gravitee.10.5.18.122.nip.io", "apikeyHeader": "X-Gravitee-Api-Key" }, "theme": { @@ -19,4 +19,4 @@ "support": { "enabled": false } - } \ No newline at end of file + } diff --git a/openshift/create_all.cmd b/openshift/create_all.cmd deleted file mode 100644 index 15a2cc3..0000000 --- a/openshift/create_all.cmd +++ /dev/null @@ -1,43 +0,0 @@ -# create pv -persistentvolumes/create_pv.cmd - -# create project -oc login -u developer -p developer -oc new-project gravitee - -# add service account for host path -oc create serviceaccount gravitee -n gravitee - -# affect policy -oc login -u system:admin -oc project gravitee -oc adm policy add-scc-to-user anyuid -z gravitee - -oc login -u developer -p developer - -set GRAVITEEIO_VERSION=1.10.4 - -# 1. definie build -# 2. start building -# 3. tag this version - -# gateway -oc new-build ../ --name=gateway --context-dir=images/gateway/ --strategy=docker --build-arg=GRAVITEEIO_VERSION=%GRAVITEEIO_VERSION% -oc start-build gateway --from-dir ../images/gateway/ --build-arg=GRAVITEEIO_VERSION=%GRAVITEEIO_VERSION% -oc tag gateway:latest gateway:%GRAVITEEIO_VERSION% - -# management-api -oc new-build ../ --name=management-api --context-dir=images/management-api/ --strategy=docker --build-arg=GRAVITEEIO_VERSION=%GRAVITEEIO_VERSION% -oc start-build management-api --from-dir ../images/management-api/ --build-arg=GRAVITEEIO_VERSION=%GRAVITEEIO_VERSION% -oc tag management-api:latest management-api:%GRAVITEEIO_VERSION% - -# management-ui -oc new-build ../ --name=management-ui --context-dir=images/management-ui/ --strategy=docker --build-arg=GRAVITEEIO_VERSION=%GRAVITEEIO_VERSION% -oc start-build management-ui --from-dir ../images/management-ui/ --build-arg=GRAVITEEIO_VERSION=%GRAVITEEIO_VERSION% -oc tag management-ui:latest management-ui:%GRAVITEEIO_VERSION% - -# import OpenShift Template -oc process -f .\template-graviteeapim.yaml | oc create -f - - - - diff --git a/openshift/create_all.sh b/openshift/create_all.sh new file mode 100755 index 0000000..54c2d7d --- /dev/null +++ b/openshift/create_all.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# create pv +persistentvolumes/create_pv.sh + +# create project +oc login -u developer -p developer +oc new-project gravitee + +# add service account for host path +oc create serviceaccount gravitee -n gravitee + +# affect policy +oc login -u admin +oc project gravitee +oc adm policy add-scc-to-user anyuid -z gravitee + +oc login -u developer -p developer +#oc project gravitee + +# get images +#oc import-image nginx:1.10.2-alpine --confirm +#oc import-image graviteeio/java:8 --confirm + +# set GRAVITEEIO_VERSION=1.10.4 +export GRAVITEEIO_VERSION=1.26.0 + + +add_secret_opt () { + export GIT_SECRET_OPT="--source-secret=git-secret" + + # create secret to gravitee project + oc create -f secret/create_secret.yml -n gravitee + # link secret to build service + for i in default deployer builder gravitee; do oc secret link $i git-secret --for=pull -n gravitee;done +} + +# 1. definie build +# 2. start building +# 3. tag this version + +# disable for secret creation +#add_secret_opt + +# gateway +oc new-build --name=gateway --binary --strategy=docker $GIT_SECRET_OPT --build-arg=GRAVITEEIO_VERSION=$GRAVITEEIO_VERSION +oc start-build gateway --wait --from-dir=gateway +sleep 5 +oc tag gateway:latest gateway:$GRAVITEEIO_VERSION + + +# management-api +oc new-build --name=management-api --binary --strategy=docker $GIT_SECRET_OPT --build-arg=GRAVITEEIO_VERSION=$GRAVITEEIO_VERSION +oc start-build management-api --wait --from-dir=management-api +sleep 5 +oc tag management-api:latest management-api:$GRAVITEEIO_VERSION + +# management-ui +oc new-build --name=management-ui --binary --strategy=docker $GIT_SECRET_OPT --build-arg=GRAVITEEIO_VERSION=$GRAVITEEIO_VERSION +oc start-build management-ui --wait --from-dir=management-ui +sleep 5 +oc tag management-ui:latest management-ui:$GRAVITEEIO_VERSION + +# import OpenShift Template +oc process -f ./template-graviteeapim.yaml | oc create -f - diff --git a/openshift/delete_all.cmd b/openshift/delete_all.sh old mode 100644 new mode 100755 similarity index 98% rename from openshift/delete_all.cmd rename to openshift/delete_all.sh index 5aecf7c..701aee7 --- a/openshift/delete_all.cmd +++ b/openshift/delete_all.sh @@ -1,3 +1,5 @@ +#!/bin/bash + #delete objects oc delete dc mongodb -n gravitee oc delete services mongodb -n gravitee diff --git a/openshift/persistentvolumes/create_pv.cmd b/openshift/persistentvolumes/create_pv.cmd deleted file mode 100644 index 1046b7e..0000000 --- a/openshift/persistentvolumes/create_pv.cmd +++ /dev/null @@ -1,5 +0,0 @@ -oc login -u system:admin -oc delete pv pv0001 pv0002 - -oc create -f pv0001.yaml -oc create -f pv0002.yaml \ No newline at end of file diff --git a/openshift/persistentvolumes/create_pv.sh b/openshift/persistentvolumes/create_pv.sh new file mode 100755 index 0000000..5bbab9f --- /dev/null +++ b/openshift/persistentvolumes/create_pv.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +oc login -u admin +oc delete pv pv0001 pv0002 + +oc create -f persistentvolumes/pv0001.yaml +oc create -f persistentvolumes/pv0002.yaml diff --git a/openshift/persistentvolumes/pv0001.yaml b/openshift/persistentvolumes/pv0001.yaml index 3015819..a77786f 100644 --- a/openshift/persistentvolumes/pv0001.yaml +++ b/openshift/persistentvolumes/pv0001.yaml @@ -9,4 +9,4 @@ spec: - ReadWriteOnce storageClassName: slow hostPath: - path: /var/lib/minishift/openshift.local.volumes/pv0001 + path: /opt/openshift_pv/pv0001 diff --git a/openshift/persistentvolumes/pv0002.yaml b/openshift/persistentvolumes/pv0002.yaml index d322613..3984134 100644 --- a/openshift/persistentvolumes/pv0002.yaml +++ b/openshift/persistentvolumes/pv0002.yaml @@ -9,4 +9,4 @@ spec: - ReadWriteOnce storageClassName: slow hostPath: - path: /var/lib/minishift/openshift.local.volumes/pv0002 \ No newline at end of file + path: /opt/openshift_pv/pv0002 diff --git a/openshift/start_all.cmd b/openshift/start_all.sh old mode 100644 new mode 100755 similarity index 95% rename from openshift/start_all.cmd rename to openshift/start_all.sh index 747a112..e6428ab --- a/openshift/start_all.cmd +++ b/openshift/start_all.sh @@ -1,3 +1,5 @@ +#!/bin/bash + oc login -u developer -p developer oc project gravitee diff --git a/openshift/stop_all.cmd b/openshift/stop_all.sh old mode 100644 new mode 100755 similarity index 95% rename from openshift/stop_all.cmd rename to openshift/stop_all.sh index 5a16182..4cbf1b6 --- a/openshift/stop_all.cmd +++ b/openshift/stop_all.sh @@ -1,3 +1,5 @@ +#!/bin/bash + oc login -u developer -p developer oc project gravitee diff --git a/openshift/template-graviteeapim.yaml b/openshift/template-graviteeapim.yaml index de65832..0c91ecc 100644 --- a/openshift/template-graviteeapim.yaml +++ b/openshift/template-graviteeapim.yaml @@ -33,12 +33,14 @@ objects: deploymentconfig: elasticsearch spec: containers: - - image: elasticsearch:2 + - image: elasticsearch:5.6.16 imagePullPolicy: IfNotPresent name: elasticsearch ports: - containerPort: 9300 protocol: TCP + - containerPort: 9200 + protocol: TCP resources: {} terminationMessagePath: /dev/termination-log volumeMounts: @@ -88,6 +90,14 @@ objects: spec: containers: - env: + - name: GRAVITEE_MANAGEMENT_MONGODB_URI + value: "mongodb://mongodb:27017/gravitee?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&socketTimeoutMS=5000" + - name: GRAVITEE_RATELIMIT_MONGODB_URI + value: "mongodb://mongodb:27017/gravitee?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&socketTimeoutMS=5000" + - name: GRAVITEE_REPORTERS_ELASTICSEARCH_ENDPOINTS_0 + value: "http://elasticsearch:9200" + - name: GRAVITEE_PLUGINS_PATH_0 + value: "$${gravitee.home}/plugins" - name: GRAVITEEIO_ELASTIC_HOST value: elasticsearch - name: GRAVITEEIO_MONGODB_HOST @@ -149,6 +159,18 @@ objects: spec: containers: - env: + - name: GRAVITEE_MANAGEMENT_MONGODB_URI + value: "mongodb://mongodb:27017/gravitee?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&socketTimeoutMS=5000" + - name: GRAVITEE_RATELIMIT_MONGODB_URI + value: "mongodb://mongodb:27017/gravitee?serverSelectionTimeoutMS=5000&connectTimeoutMS=5000&socketTimeoutMS=5000" + - name: GRAVITEE_ANALYTICS_ELASTICSEARCH_ENDPOINTS_0 + value: "http://elasticsearch:9200" + - name: GRAVITEE_USER_LOGIN_DEFAULTAPPLICATION + value: "false" + - name: GRAVITEE_PLUGINS_PATH_0 + value: "$${gravitee.home}/plugins" +# - name: GRAVITEE_PLUGINS_PATH_1 +# value: "$${gravitee.home}/plugins-ext" - name: GRAVITEEIO_ELASTIC_HOST value: elasticsearch - name: GRAVITEEIO_MONGODB_HOST @@ -310,6 +332,10 @@ objects: port: 9300 protocol: TCP targetPort: 9300 + - name: 9200-tcp + port: 9200 + protocol: TCP + targetPort: 9200 selector: deploymentconfig: elasticsearch sessionAffinity: None @@ -435,34 +461,24 @@ objects: - apiVersion: v1 kind: PersistentVolumeClaim metadata: - annotations: - pv.kubernetes.io/bind-completed: "yes" - pv.kubernetes.io/bound-by-controller: "yes" - creationTimestamp: null name: mongodata spec: accessModes: - ReadWriteOnce resources: requests: - storage: 100Mi - volumeName: pv0001 + storage: 1Gi status: {} - apiVersion: v1 kind: PersistentVolumeClaim metadata: - annotations: - pv.kubernetes.io/bind-completed: "yes" - pv.kubernetes.io/bound-by-controller: "yes" - creationTimestamp: null name: elasticdata spec: accessModes: - ReadWriteOnce resources: requests: - storage: 100Mi - volumeName: pv0002 + storage: 1Gi status: {} parameters: - name: NAMESPACE @@ -470,12 +486,12 @@ parameters: value: gravitee required: true - name: GRAVITEE_VERSION - description: Verion of gravitee to deploy - value: 1.10.4 + description: Version of gravitee to deploy + value: 1.26.0 required: true - name: OPENSHIFT_SUFFIXE description: Base of web access for openshift - value: minishift.local + value: apps.c0preprod.dedalus.lan required: true - name: STORAGE_ELASTIC description: Gi storage for elasticsearch @@ -484,4 +500,4 @@ parameters: - name: STORAGE_MONGO description: Gi storage for mongodb value: 100Mi - required: true \ No newline at end of file + required: true