Created OCP Templates for Vert.X gateway
RENAME
gateway-vertx/Dockerfile
vertx-openshift/Dockerfile
@@ -2,13 +2,12 @@ FROM jboss/base-jdk:8
LABEL maintainter="jcechace@redhat.com>" \
description="Vert.X implementation of Apiman Gateway" \
version="1.0" \
- apiman.verson="1.3.1.Final" \
apiman.component="gateway" \
apiman.platform="verx"
ENV JBOSS_HOME="/opt/jboss"
-ENV APIMAN_VERSION="1.3.1.Final"
+ENV APIMAN_VERSION="1.5.1.Final"
ENV APIMAN_HOME="${JBOSS_HOME}/apiman"
ENV APIMAN_CONFIG="${APIMAN_HOME}/configs/conf-container.json"
ENV APIMAN_REGISTRY_URI="file:///${APIMAN_HOME}/configs/registry.json"
@@ -35,7 +34,7 @@ VOLUME ${APIMAN_HOME}/configs/
EXPOSE 8080
EXPOSE 8081
-ENTRYPOINT ${APIMAN_HOME}/apiman-gateway.sh -conf "${APIMAN_CONFIG}"
+CMD ${APIMAN_HOME}/apiman-gateway.sh -conf "${APIMAN_CONFIG}"

ADD
vertx-openshift/build.sh
+#!/usr/bin/env bash
+
+OPTS=`getopt -o pn: --long push,name: -- $@`
+eval set -- "$OPTS"
+
+PUSH_TO_HUB=false
+IMAGE_LOCAL=jcechace/apiman-vertx-openshift
+
+while true; do
+ case "$1" in
+ -p | --push) PUSH_TO_HUB=true; shift ;;
+ -n | --name) IMAGE_LOCAL=$2; shift; shift;;
+ *) break ;;
+ esac
+done
+
+echo "Bulding docker image with tag '${IMAGE_LOCAL}'."
+docker build -t ${IMAGE_LOCAL} $( dirname "${BASH_SOURCE[0]}" )
+
+
+if $PUSH_TO_HUB; then
+ echo "Pushing to docker hub."
+ docker push ${IMAGE_LOCAL}:latest
+fi
+
+

RENAME
gateway-vertx/configs/conf-container.json
vertx-openshift/configs/conf-container.json
"apiman" : {
"es": {
"protocol": "${APIMAN_ES_PROTOCOL:-http}",
- "host": "${APIMAN_ES_HOST:-localhost}",
+ "host": "${APIMAN_ES_HOST:-apiman_elastic}",
"port": "${APIMAN_ES_PORT:-9200}",
"username": null,
"password": null,
},
"registry": {
- "class": "io.apiman.gateway.engine.vertx.polling.URILoadingRegistry",
+ "class": "io.apiman.gateway.engine.es.PollCachingESRegistry",
"config": {
- // Path to your apiman JSON config; refer to apiman's documentation for format description.
- // Supports: file, HTTP & HTTPS.
- "configUri": "${APIMAN_REGISTRY_URI}",
- // For HTTP/HTTPS auth is supported: BASIC, OAUTH2, KEYCLOAKOAUTH2
- // For more detail refer to the apiman documentation.
- "auth": "NONE"
+ "client": {
+ "type": "jest",
+ "protocol": "${apiman.es.protocol}",
+ "host": "${apiman.es.host}",
+ "port": "${apiman.es.port}",
+ "initialize": true,
+ "username": "${apiman.es.username}",
+ "password": "${apiman.es.password}",
+ "timeout": "${apiman.es.timeout}"//,
+ //"cache-polling-interval": 15
+ //"index": ""
+ }
}
},
"tls": {
// Enable devMode for HTTPS connections (gateway trusts any certificate).
// This should *NOT* be used in production mode. *Use with great care.*
- "devMode": "false",
+ "devMode": "${APIMAN_DEV_MODE:-false}",
// Whether self-signed certificates should be automatically trusted. *Use with great care.*
"allowSelfSigned": "${APIMAN_SSL_BACKEND_SELF_SIGNED:-false}"
// },
// Host-name to bind to for this machine.
- "hostname": "localhost",
+ // "hostname": "localhost",
// Verticle configuration
// Port - The port a given verticle listens on (where relevant)
// Count - Number of given verticle type launched, or "auto" for automatic.
"verticles": {
"http": {
- "port": "${APIMAN_VERTICLE_HTTP_PORT:-8080}",
+ "port": 8080,
"count": "auto"
},
// Configure the following SSL section to enable SSL/TLS.
"https": {
- "port": "${APIMAN_VERTICLE_HTTPS_PORT:-8443}",
+ "port": 8443,
"count": 0
},
// The Gateway API; this will be the port to set in the UI.
// e.g. http://localhost:8081 or https://gateway.machine:8081
// Configure the following SSL section to enable SSL/TLS.
"api": {
- "port": "${APIMAN_VERTICLE_API_PORT:-8081}",
+ "port": 8081,
"count": 1
}
},
"auth": {
"type": "BASIC",
"config": {
- "username": "${APIMAN_AUTH_USERNAME}",
- "password": "${APIMAN_AUTH_PASSWORD}"
+ "username": "${APIMAN_AUTH_USERNAME:-admin}",
+ "password": "${APIMAN_AUTH_PASSWORD:-admin}"
}
},

RENAME
gateway-vertx/configs/registry.json
vertx-openshift/configs/registry.json
{
"apis": [{
- "publicAPI": false,
+ "publicAPI": true,
"organizationId": "example",
"apiId": "echo",
"version": "1.0",

ADD
vertx-openshift/docker-compose.yml
+version: '3'
+services:
+ apiman_gateway:
+ container_name: apiman_gateway
+ image: jcechace/apiman-vertx-openshift
+ ports:
+ - "8082:8082"
+ - "8081:8081"
+ links:
+ - apiman_elastic
+ apiman_elastic:
+ container_name: apiman_elastic
+ image: docker.elastic.co/elasticsearch/elasticsearch:5.6.12
+ ports:
+ - "9200:9200"
+ - "9300:9300"
+ environment:
+ - discovery.type=single-node

ADD
vertx-openshift/openshift/templates/apiman-gateway-vertx.yaml
+kind: Template
+apiVersion: v1
+metadata:
+ name: "apiman-gateway"
+ annotations:
+ description: "Apiman Vert.X API gateway"
+ iconClass: "icon-load-balancer"
+ tags: "api,gateway,apiman"
+objects:
+- kind: Secret
+ apiVersion: v1
+ stringData:
+ APIMAN_AUTH_USERNAME: "${APIMAN_AUTH_USERNAME}"
+ APIMAN_AUTH_PASSWORD: "${APIMAN_AUTH_PASSWORD}"
+ metadata:
+ name: "${APIMAN_NAME}-auth-secret"
+ labels:
+ apiman: "${APIMAN_NAME}"
+ component: "gateway"
+ type: Opaque
+
+- kind: Secret
+ apiVersion: v1
+ stringData:
+ APIMAN_ES_USERNAME: "${APIMAN_ES_USERNAME}"
+ APIMAN_ES_PASSWORD: "${APIMAN_ES_PASSWORD}"
+ metadata:
+ name: "${APIMAN_NAME}-es-auth-secret"
+ labels:
+ apiman: "${APIMAN_NAME}"
+ component: "gateway"
+ type: Opaque
+
+- kind: DeploymentConfig
+ apiVersion: v1
+ metadata:
+ name: "${APIMAN_NAME}"
+ labels:
+ apiman: "${APIMAN_NAME}"
+ component: "gateway"
+ spec:
+ replicas: 1
+ selector:
+ deploymentconfig: "${APIMAN_NAME}"
+ strategy:
+ type: Rolling
+ template:
+ metadata:
+ labels:
+ deploymentconfig: "${APIMAN_NAME}"
+ spec:
+ containers:
+ - name: "${APIMAN_NAME}"
+ image: "jcechace/apiman-vertx-openshift"
+ imagePullPolicy: Always
+ ports:
+ - name: proxy
+ containerPort: 8080
+ protocol: TCP
+ - name: api
+ containerPort: 8081
+ protocol: TCP
+ env:
+ - name: APIMAN_AUTH_USERNAME
+ valueFrom:
+ secretKeyRef:
+ name: "${APIMAN_NAME}-auth-secret"
+ key: "APIMAN_AUTH_USERNAME"
+ - name: APIMAN_AUTH_PASSWORD
+ valueFrom:
+ secretKeyRef:
+ name: "${APIMAN_NAME}-auth-secret"
+ key: "APIMAN_AUTH_PASSWORD"
+ - name: APIMAN_ES_PROTOCOL
+ value: "${APIMAN_ES_PROTOCOL}"
+ - name: APIMAN_ES_HOST
+ value: "${APIMAN_ES_HOST}"
+ - name: APIMAN_ES_PORT
+ value: "${APIMAN_ES_HOST}"
+ - name: APIMAN_ES_USERNAME
+ valueFrom:
+ secretKeyRef:
+ name: "${APIMAN_NAME}-es-auth-secret"
+ key: "APIMAN_ES_USERNAME"
+ - name: APIMAN_ES_PASSWORD
+ valueFrom:
+ secretKeyRef:
+ name: "${APIMAN_NAME}-es-auth-secret"
+ key: "APIMAN_ES_PASSWORD"
+ - name: APIMAN_DEV_MODE
+ value: "${APIMAN_DEV_MODE}"
+ triggers:
+ - type: ConfigChange
+
+- kind: Service
+ apiVersion: v1
+ metadata:
+ name: "${APIMAN_NAME}"
+ labels:
+ apiman: "${APIMAN_NAME}"
+ component: "gateway"
+ spec:
+ ports:
+ - name: http
+ port: 8080
+ protocol: TCP
+ targetPort: 8080
+ - name: api
+ port: 8081
+ protocol: TCP
+ targetPort: 8081
+ selector:
+ deploymentconfig: "${APIMAN_NAME}"
+
+- kind: Route
+ apiVersion: v1
+ metadata:
+ name: apiman-gateway-http
+ labels:
+ apiman: "${APIMAN_NAME}"
+ spec:
+ to:
+ kind: Service
+ name: ${APIMAN_NAME}
+ port:
+ targetPort: http
+ tls:
+ termination: edge
+ insecureEdgeTerminationPolicy: Allow
+
+- kind: Route
+ apiVersion: v1
+ metadata:
+ name: apiman-gateway-api
+ labels:
+ apiman: "${APIMAN_NAME}"
+ spec:
+ to:
+ kind: Service
+ name: ${APIMAN_NAME}
+ port:
+ targetPort: api
+ tls:
+ termination: edge
+ insecureEdgeTerminationPolicy: Allow
+
+parameters:
+- name: APIMAN_NAME
+ description: "Name of the Apiman API Gateway"
+ value: apiman
+- name: APIMAN_ES_PROTOCOL
+ description: "Protocol used to connect to ElasticSearch cluester"
+ value: "http"
+- name: APIMAN_ES_HOST
+ decritpion: "ElasticSearch host"
+ required: true
+- name: APIMAN_ES_PORT
+ value: "9200"
+ description: "Port used to connect to ElasticSearch cluster"
+- name: APIMAN_ES_USERNAME
+ value: ""
+ description: "Username used to connect to ElasticSearch cluester"
+- name: APIMAN_ES_PASSWORD
+ value: ""
+ description: "Password used to connect to ElasticSearch cluester"
+- name: APIMAN_DEV_MODE
+ description: "Debug mode"
+ value: "true"
+- name: APIMAN_AUTH_USERNAME
+ description: "Username used to access gateway API"
+ value: "apiman"
+- name: APIMAN_AUTH_PASSWORD
+ description: "Password used to access gateway API"
+ generate: "expression"
+ from: "[a-zA-Z0-9]{20}"

Created OCP Templates for Vert.X gateway