1:docker安装遵循官方手册git
2:安装konggithub
参考文档:https://getkong.org/install/docker/ docker
安装过程基本和文档一致,文档十分简单清晰。数据库
但应注意,为了最新版kong-dashboard,使用的kong镜像为 0.12版本。post
不然kong-dashboard不支持。url
注意:本文档使用postgres数据库spa
2.1 安装postgrescode
docker run -d --name kong-database -p 5432:5432 -e "POSTGRES_USER=kong" -e "POSTGRES_DB=kong" postgresserver
2.2 文档
docker run --rm --link kong-database:kong-database -e "KONG_DATABASE=postgres" -e "KONG_PG_HOST=kong-database" -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" kong:0.12 kong migrations up
若是使用的cassandra,KONG_DATABASE属性对应修改成cassandra就能够了。
2.3
docker run -d --name kong \
--link kong-database:kong-database \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-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" \
-e "KONG_ADMIN_LISTEN_SSL=0.0.0.0:8444" \
-p 8000:8000 \
-p 8443:8443 \
-p 8001:8001 \
-p 8444:8444 \
kong:0.12
3: 添加kong-dashboard
参考文档:https://github.com/PGBI/kong-dashboard
注意:kong-dashboard应该使用最新版,旧版本(如v2)有bug,访问kong server一直报错。
# Start Kong Dashboard docker run --rm -p 8080:8080 pgbi/kong-dashboard start --kong-url http://kong:8001 # Start Kong Dashboard on a custom port docker run --rm -p [port]:8080 pgbi/kong-dashboard start --kong-url http://kong:8001 # Start Kong Dashboard with basic auth docker run --rm -p 8080:8080 pgbi/kong-dashboard start \ --kong-url http://kong:8001 --basic-auth user1=password1 user2=password2 # See full list of start options docker run --rm -p 8080:8080 pgbi/kong-dashboard start --help
以上。