mirror of
https://github.com/openfaas/faas.git
synced 2025-06-17 12:46:59 +00:00
Updating Kong to use the same network as FaaS
Signed-off-by: Jono <jono@foodnotblogs.com>
This commit is contained in:
parent
13852a930d
commit
ab1e913492
@ -18,20 +18,20 @@ Below is a demo of how you could use Kong as an authentication layer for OpenFaa
|
|||||||
|
|
||||||
## Setup Kong
|
## Setup Kong
|
||||||
|
|
||||||
docker run -d --name kong-database \
|
docker service create --network func_functions --detach=false \
|
||||||
-p 5432:5432 \
|
--name kong-database \
|
||||||
-e "POSTGRES_USER=kong" \
|
-p 5432:5432 \
|
||||||
-e "POSTGRES_DB=kong" \
|
-e "POSTGRES_USER=kong" \
|
||||||
postgres:9.4
|
-e "POSTGRES_DB=kong" \
|
||||||
|
postgres:9.4
|
||||||
|
|
||||||
docker run --rm \
|
docker service create --network func_functions --detach=false \
|
||||||
--link kong-database:kong-database \
|
--restart-condition=none --name=kong-migrations \
|
||||||
-e "KONG_DATABASE=postgres" \
|
-e "KONG_DATABASE=postgres" \
|
||||||
-e "KONG_PG_HOST=kong-database" \
|
-e "KONG_PG_HOST=kong-database" \
|
||||||
kong:latest kong migrations up
|
kong:latest kong migrations up
|
||||||
|
|
||||||
docker run -d --name kong \
|
docker service create --network func_functions --name kong \
|
||||||
--link kong-database:kong-database \
|
|
||||||
-e "KONG_DATABASE=postgres" \
|
-e "KONG_DATABASE=postgres" \
|
||||||
-e "KONG_PG_HOST=kong-database" \
|
-e "KONG_PG_HOST=kong-database" \
|
||||||
-e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
|
-e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
|
||||||
@ -45,20 +45,19 @@ Below is a demo of how you could use Kong as an authentication layer for OpenFaa
|
|||||||
kong:latest
|
kong:latest
|
||||||
|
|
||||||
|
|
||||||
## Get a route to the OpenFaaS server
|
|
||||||
|
|
||||||
FAASTHOST=`hostname -i`
|
|
||||||
|
|
||||||
|
|
||||||
## Put Kong in front of a single function
|
## Put Kong in front of a single function
|
||||||
|
|
||||||
sleep 5 # wait for Kong to be ready
|
echo Waiting for Kong to be ready
|
||||||
|
until $(curl --output /dev/null --silent --head --fail http://localhost:8001); do
|
||||||
|
printf '.'
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
curl -i -X POST \
|
curl -i -X POST \
|
||||||
--url http://localhost:8001/apis/ \
|
--url http://localhost:8001/apis/ \
|
||||||
--data 'name=echoit' \
|
--data 'name=echoit' \
|
||||||
--data 'uris=/echo' \
|
--data 'uris=/echo' \
|
||||||
--data 'upstream_url=http://'$FAASTHOST':8080/function/func_echoit'
|
--data 'upstream_url=http://gateway:8080/function/func_echoit'
|
||||||
|
|
||||||
curl localhost:8000/echo -d 'hello there'
|
curl localhost:8000/echo -d 'hello there'
|
||||||
|
|
||||||
@ -68,7 +67,7 @@ Below is a demo of how you could use Kong as an authentication layer for OpenFaa
|
|||||||
--url http://localhost:8001/apis/ \
|
--url http://localhost:8001/apis/ \
|
||||||
--data 'name=functions' \
|
--data 'name=functions' \
|
||||||
--data 'uris=/functs' \
|
--data 'uris=/functs' \
|
||||||
--data 'upstream_url=http://'$FAASTHOST':8080/function'
|
--data 'upstream_url=http://gateway:8080/function'
|
||||||
|
|
||||||
curl localhost:8000/functs/func_echoit -d 'hello there'
|
curl localhost:8000/functs/func_echoit -d 'hello there'
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user