首页 > 其他分享 >使用Kong网关API接口配置

使用Kong网关API接口配置

时间:2022-10-19 13:22:23浏览次数:77  
标签:网关 -- data auth Kong API upstream IPAddress 8001

一、Upstream
1、创建Upstream:
curl -i -X POST IPAddress:8001/upstreams -d 'name=upstream-test' -d 'slots=1000'

2、创建Targets目标地址并且关联Upstream:
curl -i -X POST IPAddress:8001/upstreams/upstream-test/targets -d 'target=10.20.30.40:1090' -d 'weight=100'

3、删除Target目标地址:
curl -i -X DELETE IPAddress:8001/upstreams/upstream-auth/targets/10.20.30.40:1090

4、删除Upstream
curl -i -X DELETE IPAddress:8001/upstreams/upstream-test

5、修改Upstream
curl -i -X PATCH IPAddress:8001/upstreams/upstream-auth --data 'slots=1001'

二、Service
1、创建Service,关联Upstream
curl -i -X POST IPAddress:8001/services/ --data 'name=ServiceName' --data 'host=upstream-auth'
创建的Service名称叫ServiceName,转发到upstream-auth

转发ip+port:curl -i -X POST IPAddress:8001/services/ --data 'name=ServiceName' --data 'host=192.168.1.1' --data 'port=8080'

其它配置可选项:
destinations=null
port=8080
path=/api/interface

2、修改Service
curl -i -X PATCH IPAddress:8001/services/auth --data 'port=88'

3、删除Service
curl -i -X DELETE IPAddress:8001/services/auth

4、查看Service
curl -i -X GET IPAddress:8001/services/ --data 'name=auth'

三、Route
1、创建Route并关联Service
curl -i -X POST IPAddress:8001/services/auth/routes --data 'name=route-auth' --data 'hosts[]=up.hello' --data 'paths[]=/h/auth-srv'
Route的名称叫route-auth,hosts[]的值是up.hello,匹配路径是/h/auth-srv
其它配置可选项:
destinations=null
strip_path=true
preserve_host=false

2、修改Route
curl -i -X PATCH IPAddress:8001/routes/route-auth --data 'paths[]=/haha'

3、删除Route
curl -i -X DELETE IPAddress:8001/routes/route-auth

4、查看Route
curl -i -X POST IPAddress:8001/services/auth/routes --data 'name=route-auth'

Plugins、Certificates等参照Kong网关官方文档
https://docs.konghq.com/gateway-oss/2.1.x/admin-api/

标签:网关,--,data,auth,Kong,API,upstream,IPAddress,8001
From: https://www.cnblogs.com/hm1825/p/16805902.html

相关文章