You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by cs...@apache.org on 2018/05/09 00:37:53 UTC

[incubator-openwhisk-devtools] branch master updated: Integrated OW GW and existing API Manangement (#123)

This is an automated email from the ASF dual-hosted git repository.

csantanapr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-devtools.git


The following commit(s) were added to refs/heads/master by this push:
     new 1e95e39  Integrated OW GW and existing API Manangement (#123)
1e95e39 is described below

commit 1e95e3982edecda40cf11fd3cc0bdd884f10136f
Author: ddragosd <dd...@gmail.com>
AuthorDate: Tue May 8 17:37:51 2018 -0700

    Integrated OW GW and existing API Manangement (#123)
---
 docker-compose/Makefile                            | 49 ++++++++++++++++++----
 docker-compose/README.md                           |  3 +-
 .../whisk-docker-compose.conf                      |  0
 docker-compose/apigateway/rclone/rclone.conf       | 10 +++++
 docker-compose/docker-compose.yml                  | 36 +++++++++++++---
 5 files changed, 82 insertions(+), 16 deletions(-)

diff --git a/docker-compose/Makefile b/docker-compose/Makefile
index 2d8e870..25c80fe 100644
--- a/docker-compose/Makefile
+++ b/docker-compose/Makefile
@@ -123,7 +123,7 @@ download-cli:
 	fi
 
 .PHONY: run
-run: print-host check-required-ports setup start-docker-compose init-couchdb init-whisk-cli
+run: print-host check-required-ports setup start-docker-compose init-couchdb init-whisk-cli init-api-management
 
 print-host:
 	echo "host ip address: ${DOCKER_HOST_IP}"
@@ -164,21 +164,39 @@ check-kafka-ports:
 	done
 	echo " ... OK"
 
-
-
-
 .PHONY: setup
 setup:
-	mkdir -p ~/tmp/openwhisk/apigateway/ssl
-	$(OPENWHISK_PROJECT_HOME)/ansible/files/genssl.sh $(DOCKER_HOST_IP) server $(OPENWHISK_PROJECT_HOME)/ansible/roles/nginx/files
-	cp $(OPENWHISK_PROJECT_HOME)/ansible/roles/nginx/files/*.pem ~/tmp/openwhisk/apigateway/ssl
-	cp -r ./apigateway/* ~/tmp/openwhisk/apigateway/
+	mkdir -p ~/tmp/openwhisk
 	> ~/tmp/openwhisk/local.env
 	printf "DOCKER_BINARY=$(DOCKER_BINARY)\n" >> ~/tmp/openwhisk/local.env
 	printf "DOCKER_COMPOSE_HOST=$(DOCKER_HOST_IP)\n" >> ~/tmp/openwhisk/local.env
 	printf "DOCKER_REGISTRY=$(DOCKER_REGISTRY)\n" >> ~/tmp/openwhisk/local.env
 	printf "DOCKER_IMAGE_PREFIX=$(DOCKER_IMAGE_PREFIX)\n" >> ~/tmp/openwhisk/local.env
 
+	echo "  ... preparing api-gateway configuration"
+	rm -rf ~/tmp/openwhisk/api-gateway-config
+	mkdir -p ~/tmp/openwhisk/api-gateway-config/api-gateway
+	cp -r ./apigateway/* ~/tmp/openwhisk/api-gateway-config/api-gateway/
+	cp -r ./apigateway/rclone ~/tmp/openwhisk
+	$(shell cat ~/tmp/openwhisk/local.env) docker-compose --project-name openwhisk up minio 2>&1 > ~/tmp/openwhisk/setup.log &
+	until (curl --silent http://$(DOCKER_HOST_IP):9001/); do printf '.'; sleep 5; done
+	docker run --rm -v ~/tmp/openwhisk/rclone:/root/.config/rclone \
+					--link="openwhisk_minio_1:minio.docker" --network=openwhisk_default \
+					--entrypoint=rclone openwhisk/apigateway mkdir minio:api-gateway
+	docker run --rm -v ~/tmp/openwhisk/api-gateway-config/api-gateway/generated-conf.d:/etc/api-gateway/generated-conf.d \
+					-v ~/tmp/openwhisk/rclone:/root/.config/rclone \
+					--link="openwhisk_minio_1:minio.docker" --network=openwhisk_default \
+					--entrypoint=rclone openwhisk/apigateway copy --exclude .git /etc/api-gateway/ minio:api-gateway/
+	# $(shell cat ~/tmp/openwhisk/local.env) docker-compose --project-name openwhisk stop minio
+	# $(shell cat ~/tmp/openwhisk/local.env) docker-compose --project-name openwhisk rm -f minio
+	$(OPENWHISK_PROJECT_HOME)/ansible/files/genssl.sh $(DOCKER_HOST_IP) server $(OPENWHISK_PROJECT_HOME)/ansible/roles/nginx/files
+	mkdir -p ~/tmp/openwhisk/api-gateway-ssl
+	cp $(OPENWHISK_PROJECT_HOME)/ansible/roles/nginx/files/*.pem ~/tmp/openwhisk/api-gateway-ssl
+
+.PHONY: gw 
+gw:
+	$(shell cat ~/tmp/openwhisk/local.env) docker-compose --project-name openwhisk up apigateway
+
 .PHONY: restart
 restart: stop rm start-docker-compose
 
@@ -236,8 +254,14 @@ init-whisk-cli:
 	echo "waiting for the Whisk controller to come up ... "
 	until $$(curl --output /dev/null --silent --head --fail http://$(DOCKER_HOST_IP):8888/ping); do printf '.'; sleep 5; done
 	echo "initializing CLI ... "
-	$(WSK_CLI) -v property set --namespace guest --auth `cat $(OPENWHISK_PROJECT_HOME)/ansible/files/auth.guest` --apihost $(DOCKER_HOST_IP):443 -i
+	$(WSK_CLI) -v property set --namespace guest --auth `cat $(OPENWHISK_PROJECT_HOME)/ansible/files/auth.guest` --apihost https://$(DOCKER_HOST_IP) -i
 
+.PHONY: init-api-management
+init-api-management:
+	$(WSK_CLI) -v property set --namespace whisk.system --auth `cat $(OPENWHISK_PROJECT_HOME)/ansible/files/auth.whisk.system` --apihost $(DOCKER_HOST_IP) -i
+	GW_USER="" GW_PWD="" GW_HOST_V2="http://$(DOCKER_HOST_IP):9000/v2" OPENWHISK_HOME=$(OPENWHISK_PROJECT_HOME) \
+		$(OPENWHISK_PROJECT_HOME)/ansible/roles/routemgmt/files/installRouteMgmt.sh $(shell cat $(OPENWHISK_PROJECT_HOME)/ansible/files/auth.whisk.system) $(DOCKER_HOST_IP) /whisk.system $(WSK_CLI)
+	$(WSK_CLI) -v property set --namespace guest --auth `cat $(OPENWHISK_PROJECT_HOME)/ansible/files/auth.guest` --apihost $(DOCKER_HOST_IP) -i
 
 .PHONY: init-catalog
 init-catalog:
@@ -275,6 +299,13 @@ hello-world: create-hello-world-function
 	    && echo "invokation result:" $$res \
 	    && (echo $$res | grep "Hello, World") || ($(WSK_CLI) -i action delete hello && tail -n 200 ~/tmp/openwhisk/invoker/logs/invoker-local_logs.log ~/tmp/openwhisk/controller/logs/controller-local_logs.log && exit 1)
 
+	echo "$$(tput setaf 4) creating an API from the hello function ...$$(tput sgr0)"
+	$(WSK_CLI) -i action update "/guest/hello" --web true
+	web_action=`$(WSK_CLI) -i api create /hello /world get hello --response-type json | tail -n 1` \
+	    && echo "invoking: " $$web_action \
+	    && (echo $$web_action | xargs curl -sS | grep "Hello, World") || ($(WSK_CLI) -i action delete hello && echo "Error invoking the web action" && tail -n 200 ~/tmp/openwhisk/invoker/logs/invoker-local_logs.log ~/tmp/openwhisk/controller/logs/controller-local_logs.log && exit 1)
+	$(WSK_CLI) -i api list /hello
+
 	echo "$$(tput setaf 1)deleting the function ...$$(tput sgr0)"
 	$(WSK_CLI) -i action delete hello
 	rm hello.js
diff --git a/docker-compose/README.md b/docker-compose/README.md
index d0c58a0..6ca4866 100644
--- a/docker-compose/README.md
+++ b/docker-compose/README.md
@@ -18,7 +18,8 @@ The following are required to build and deploy OpenWhisk with Docker Compose:
 
 These ports must be available:
 
-- `80` and `443` for the API Gateway
+- `80`, `443`, `9000`, `9001`, and `9090` for the API Gateway
+- `6379` for Redis
 - `2181` for Zookeeper
 - `5984` for CouchDB
 - `8085` for OpenWhisk's Invoker
diff --git a/docker-compose/apigateway/conf/whisk-docker-compose.conf b/docker-compose/apigateway/generated-conf.d/whisk-docker-compose.conf
similarity index 100%
rename from docker-compose/apigateway/conf/whisk-docker-compose.conf
rename to docker-compose/apigateway/generated-conf.d/whisk-docker-compose.conf
diff --git a/docker-compose/apigateway/rclone/rclone.conf b/docker-compose/apigateway/rclone/rclone.conf
new file mode 100644
index 0000000..741d899
--- /dev/null
+++ b/docker-compose/apigateway/rclone/rclone.conf
@@ -0,0 +1,10 @@
+[minio]
+type = s3
+provider = Minio
+env_auth = false
+access_key_id = 5VCTEQOQ0GR0NV1T67GN
+secret_access_key = 8MBK5aJTR330V1sohz4n1i7W5Wv/jzahARNHUzi3
+region = other-v2-signature
+endpoint = http://minio.docker:9000
+location_constraint = us-east-1
+acl = public-read
\ No newline at end of file
diff --git a/docker-compose/docker-compose.yml b/docker-compose/docker-compose.yml
index f5b6015..ee87806 100644
--- a/docker-compose/docker-compose.yml
+++ b/docker-compose/docker-compose.yml
@@ -124,25 +124,49 @@ services:
 
   # The API Gateway is currently used to expose the Controller API
   #   see apigateway/conf/whisk-docker-compose.conf
+  # Minio is used to mock an object storage ( i.e. S3) that hosts the api-gateway configuration.
+  # Minio also exposes a web UI to browse the files: http://localhost:9001/minio/api-gateway/
+  minio:
+    image: minio/minio:RELEASE.2018-05-04T23-13-12Z
+    command:
+      - server
+      - /data
+    environment:
+      - MINIO_ACCESS_KEY=5VCTEQOQ0GR0NV1T67GN
+      - MINIO_SECRET_KEY=8MBK5aJTR330V1sohz4n1i7W5Wv/jzahARNHUzi3
+    volumes:
+      - ~/tmp/openwhisk/minio:/data:rw
+    ports:
+      - "9001:9000"
   redis:
     image: redis:2.8
-    expose:
-      - "6379"
+    ports:
+      - "6379:6379"
   apigateway:
-    image: adobeapiplatform/apigateway:1.1.0
+    image: openwhisk/apigateway:latest
     links:
       - controller:whisk.controller
       - redis:redis.docker
+      - minio:minio.docker
+    environment:
+      - REDIS_HOST=${DOCKER_COMPOSE_HOST}
+      - REDIS_PORT=6379
+      - PUBLIC_MANAGEDURL_PORT=9090
+      - PUBLIC_MANAGEDURL_HOST=${DOCKER_COMPOSE_HOST}
+      - REMOTE_CONFIG=minio:api-gateway
     depends_on:
       - controller
       - redis
+      - minio
     volumes:
-      - ~/tmp/openwhisk/apigateway/ssl:/etc/ssl:ro
-      - ~/tmp/openwhisk/apigateway/conf:/etc/api-gateway/generated-conf.d:ro
-      - ~/tmp/openwhisk/apigateway/env.conf:/etc/api-gateway/environment.conf.d:ro
+      - ~/tmp/openwhisk/api-gateway-ssl:/etc/ssl:ro
+      - ~/tmp/openwhisk/api-gateway-config/api-gateway/generated-conf.d:/etc/api-gateway/generated-conf.d
+      - ~/tmp/openwhisk/rclone:/root/.config/rclone:rw
     ports:
       - "80:80"
       - "443:443"
+      - "9000:9000"
+      - "9090:8080"
 
   kafka-rest:
     image: confluentinc/cp-kafka-rest:3.3.1

-- 
To stop receiving notification emails like this one, please contact
csantanapr@apache.org.