微服务网关kong

kong

部署

  #创建网络
  docker network create kong-net
  #部署数据库
  docker run -d --name kong-database \
  --network=kong-net \
  -p 5432:5432 \
  -e "POSTGRES_USER=kong" \
  -e "POSTGRES_DB=kong" \
  -e "POSTGRES_PASSWORD=kong" \
  --restart always \
  postgres:9.6

  #  使用临时Kong容器运行进行数据库初始化
  docker run --rm \
  --network=kong-net \
  -e "KONG_DATABASE=postgres" \
  -e "KONG_PG_HOST=kong-database" \
  -e "KONG_PG_USER=kong" \
  -e "KONG_PG_PASSWORD=kong" \
  -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
  kong:latest kong migrations bootstrap

  #  启动Kong
  docker run -d --name kong \
  --network=kong-net \
  -e "KONG_DATABASE=postgres" \
  -e "KONG_PG_HOST=kong-database" \
  -e "KONG_PG_USER=kong" \
  -e "KONG_PG_PASSWORD=kong" \
  -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
  -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
  -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
  -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
  -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
  -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
  -p 8000:8000 \
  -p 8443:8443 \
  -p 8001:8001 \
  -p 8444:8444 \
  --restart always \
  kong:latest


  #  konga的安装

  #初始化数据
  docker run --rm  --network=kong-net pantsel/konga:latest -c prepare \
  -a postgres -u postgresql://kong:kong@kong-database:5432/konga_db

  #  运行Konga
  docker run -p 1337:1337 \
  --network=kong-net \
  -e "KONG_DATABASE=postgres" \
  -e "KONG_PG_HOST=kong-database" \
  -e "KONG_PG_USER=kong" \
  -e "KONG_PG_PASSWORD=kong" \
  -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
  -e "DB_DATABASE=konga_db" \
  -e "KONGA_HOOK_TIMEOUT=120000" \
  --name konga \
  pantsel/konga
View Code

注册服务

 

注册路由

 

插件地址

https://docs.konghq.com/hub/

 

生成toekn

https://jwt.io/#debugger-io

安装zipkin

docker run -d --restart always -p 9411:9411 --name zipkin openzipkin/zipkin 

 对路由注册链路追踪

POST http://192.168.10.21:8001/routes/a26a8bd7-8cd5-4a14-b144-6612f3fd13d3/plugins
Content-Type: application/x-www-form-urlencoded

name=zipkin&config.http_endpoint=http://192.168.10.21:9411/api/v2/spans&config.sample_ratio=1
View Code

 

12

 

posted @ 2021-05-01 13:53  jiuchen  阅读(92)  评论(0编辑  收藏  举报