项目作者: ansrivas

项目描述 :
Initial experiments with Kong
高级语言: Dockerfile
项目地址: git://github.com/ansrivas/kong-experiments.git
创建时间: 2019-02-04T23:24:53Z
项目社区:https://github.com/ansrivas/kong-experiments

开源协议:MIT License

下载


Using Kong as an API Gateway:

Requirements:

  1. docker-engine
  2. docker-compose
  3. curl

Usage:

  1. Run the services using docker-compose up in one terminal.
  2. In about 15 seconds all the service should be up and running.
  3. Verify that you have 3 services running using docker ps.
    • flask web app
    • postgres database
    • kong
  4. At this point check if the admin-url of kong is reachable:

    curl -i http://localhost:8001/

  5. Now register your local flask app with a unique name: flask-greeter

    1. curl -i -X POST \
    2. --url http://localhost:8001/services/ \
    3. --data 'name=flask-greeter' \
    4. --data 'url=http://0.0.0.0:5000'
  6. Define its unique hostname (flask-greeter.com) and register the route:

    1. curl -i -X POST \
    2. --url http://localhost:8001/services/flask-greeter/routes \
    3. --data 'hosts[]=flask-greeter.com'
  7. Now test the follow routes to see if they are properly redirected:

    1. curl -i -X GET \
    2. --url http://localhost:8000/ \
    3. --header 'Host: flask-greeter.com'
    1. curl -i -X GET \
    2. --url http://localhost:8000/user/MYNAME \
    3. --header 'Host: flask-greeter.com'