1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# start database
docker run -d --name kong-database \
--network=kong-net \
-p 5432:5432 \
-e "POSTGRES_USER=kong" \
-e "POSTGRES_DB=kong" \
-e "POSTGRES_PASSWORD=123456" \
-e "POSTGRES_HOST_AUTH_METHOD=trust" \
postgres:9.6
# init database
docker run --rm \
--network=kong-net \
-e "KONG_LOG_LEVEL=debug" \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_PASSWORD=123456" \
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
kong:latest kong migrations bootstrap
# kong start
docker run -d --name kong \
--network=kong-net \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_PASSWORD=123456" \
-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 \
kong:latest
#kongga init
docker run --rm --network=kong-net --link kong-database pantsel/konga:latest -c prepare -a postgres -u postgresql://kong:123456@kong-database:5432/konga
# start konga
docker run -itd -p 1337:1337 --network kong-net --name konga \
--link kong-local --link kong-database \
-e "NODE_ENV=production" \
-e "DB_ADAPTER=postgres" \
-e "DB_URI=postgresql://kong:123456@kong-database:5432/konga" \
pantsel/konga:latest
|
docker network create kong-net
添加一个服务
rl -i -X POST http://localhost:8001/services
–data name=hello-service
–data url=‘http://xxx.xxx.xxx.xxx:8081/hello'
HTTP/1.1 201 Created
Date: Mon, 11 Dec 2023 14:45:19 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
Content-Length: 384
X-Kong-Admin-Latency: 56
Server: kong/2.7.0
curl -i -X POST
–url http://localhost:8001/services/hello-service/routes
–data ‘paths[]=/hello’
–data name=hello-route
$ curl -i -X POST
–url http://localhost:8001/services/hello-service/routes
–data ‘paths[]=/hello’
–data name=hello-route
1
2
3
|
curl -i -X POST http://localhost:8001/services \
--data name=hello-service \
--data url='http://xxx.xxx.xxx.xxx:8081/hello'
|