kong 0.14到2.0版本 API变更
kong 0.14到2.0X版本 API变更
Service Object
对象实体Json Demo
1 | { |
新增
POST /services/
Request json对象参数 | 0.14 | 2.0x |
---|---|---|
The Service name | name | name |
The protocol used to communicate with the upstream. Accepted values are: “grpc”, “grpcs”, “http”, “https”, “tcp”, “tls”. Defaults to “http”. | protocol | protocol |
The host of the upstream server. | host | host |
The upstream server port. Defaults to 80. | port | port |
The path to be used in requests to the upstream server. | path | path |
The number of retries to execute upon failure to proxy. The default is 5. | retries | retries |
The timeout in milliseconds for establishing a connection to the upstream server. Defaults to 60000. | connect_timeout | connect_timeout |
The timeout in milliseconds between two successive write operations for transmitting a request to the upstream server. Defaults to 60000. | write_timeout | write_timeout |
The timeout in milliseconds between two successive read operations for transmitting a request to the upstream server. Defaults to 60000. | read_timeout | read_timeout |
Shorthand attribute to set protocol, host, port and path at once. This attribute is write-only (the Admin API never “returns” the url). | url | url |
An optional set of strings associated with the Service, for grouping and filtering | tags | |
Certificate to be used as client certificate while TLS handshaking to the upstream server. With form-encoded, the notation is client_certificate.id= |
client_certificate |
查询
GET /services/{service name or id}
GET /routes/{route id}/service
GET /services/ (offset、size可分页)
2.0x 新增接口
GET /certificates/{certificate id}/services/{service name or id}
GET /routes/{route name or id}/service
GET /plugins/{plugin id}/service
更新
PATCH /services/{name or id}
PATCH /routes/{route id}/service
2.0x 新增接口
PATCH /certificates/{certificate id}/services/{service name or id}
PATCH /routes/{route name or id}/service
PATCH /plugins/{plugin id}/service
更新或者新建
PUT /services/{name or id}
2.0x 新增接口
PUT /certificates/{certificate id}/services/{service name or id}
PUT /routes/{route name or id}/service
PUT /plugins/{plugin id}/service
删除
DELETE /services/{name or id}
2.0x 新增接口
DELETE /certificates/{certificate id}/services/{service name or id}
DELETE /routes/{route name or id}/service
Route Object
对象实体Json Demo
1 | { |
新增
POST /routes/
Request json对象参数 | 0.14 | 2.0x |
---|---|---|
A list of the protocols this Route should allow. When set to [“https”], HTTP requests are answered with a request to upgrade to HTTPS. Defaults to [“http”, “https”]. | protocols | protocols |
A list of HTTP methods that match this Route. | methods | methods |
A list of domain names that match this Route. With form-encoded, the notation is hosts[]=example.com&hosts[]=foo.test. With JSON, use an Array. | hosts | hosts |
A list of paths that match this Route. With form-encoded, the notation is paths[]=/foo&paths[]=/bar. With JSON, use an Array. | paths | paths |
Determines the relative order of this Route against others when evaluating regex paths. Routes with higher numbers will have their regex paths evaluated first. Defaults to 0. | regex_priority | regex_priority |
When matching a Route via one of the paths, strip the matching prefix from the upstream request URL. Defaults to true. | strip_path | strip_path |
When matching a Route via one of the hosts domain names, use the request Host header in the upstream request headers. By default set to false, and the upstream Host header will be that of the Service’s host. | preserve_host | preserve_host |
The Service this Route is associated to. | service | service |
The name of the Route. | name | |
One or more lists of values indexed by header name that will cause this Route to match if present in the request. | headers | |
The status code Kong responds with when all properties of a Route match except the protocol i.e. if the protocol of the request is HTTP instead of HTTPS | https_redirect_status_code | |
Controls how the Service path, Route path and requested path are combined when sending a request to the upstream. | path_handling | |
A list of SNIs that match this Route when using stream routing. | snis | |
A list of IP sources of incoming connections that match this Route when using stream routing. | sources | |
A list of IP destinations of incoming connections that match this Route when using stream routing. | destinations | |
An optional set of strings associated with the Route, for grouping and filtering. | tags |
查询
GET /routes/{id}
GET /routes (offset、size可分页)
GET /services/{service name or id}/routes
2.0x 新增接口
GET /routes/{route name or id}
GET /services/{service name or id}/routes/{route name or id}
GET /plugins/{plugin id}/route
更新
PATCH /routes/{id}
2.0x 新增接口
PATCH /routes/{route name or id}
PATCH /services/{service name or id}/routes/{route name or id}
PATCH /plugins/{plugin id}/route
更新或者新建
PUT /routes/{id}
2.0x 新增接口
PUT /routes/{route name or id}
PUT /services/{service name or id}/routes/{route name or id}
PUT /plugins/{plugin id}/route
删除
DELETE /routes/{id}
2.0x 新增接口
DELETE /routes/{route name or id}
DELETE /services/{service name or id}/routes/{route name or id}
Plugin Object
对象实体Json Demo
1 | { |
新增
POST /plugins/
Request json对象参数 | 0.14 | 2.0x |
---|---|---|
The name of the Plugin that’s going to be added. Currently the Plugin must be installed in every Kong instance separately. | name | name |
The unique identifier of the consumer that overrides the existing settings for this specific consumer on incoming requests. | consumer_id | consumer |
The unique identifier of the service that overrides the existing settings for this specific service on incoming requests. | service_id | service |
The unique identifier of the route that overrides the existing settings for this specific route on incoming requests. | route_id | route |
The configuration properties for the Plugin which can be found on the plugins documentation page in the Kong Hub. | config | config |
Whether the plugin is applied. Default: true. | enabled | enabled |
. For example, plugins that only work in stream mode will only support “tcp” and “tls”. Defaults to [“grpc”, “grpcs”, “http”, “https”]. | protocols | |
An optional set of strings associated with the Plugin, for grouping and filtering | tags |
2.0x 新增接口
POST /routes/{route id}/plugins
POST /services/{service id}/plugins
POST /consumers/{consumer id}/plugins
查询
GET /plugins/{id}
GET /plugins/
GET /plugins/enabled
GET /plugins/schema/{plugin name}
2.0x 新增接口
GET /routes/{route id}/plugins
GET /services/{service id}/plugins
GET /consumers/{consumer id}/plugins
GET /routes/{route name or id}/plugins/{plugin id}
GET /services/{service name or id}/plugins/{plugin id}
GET /consumers/{consumer username or id}/plugins/{plugin id}
更新
PATCH /plugins/{plugin id}
2.0x 新增接口
PATCH /routes/{route name or id}/plugins/{plugin id}
PATCH /services/{service name or id}/plugins/{plugin id}
PATCH /consumers/{consumer username or id}/plugins/{plugin id}
更新或者新建
PUT /plugins/ 在2.0 修改为 PUT /plugins/{plugin id}
2.0x 新增接口
PUT /routes/{route name or id}/plugins/{plugin id}
PUT /services/{service name or id}/plugins/{plugin id}
PUT /consumers/{consumer username or id}/plugins/{plugin id}
删除
DELETE /plugins/{plugin id}
2.0x 新增接口
DELETE /routes/{route name or id}/plugins/{plugin id}
DELETE /services/{service name or id}/plugins/{plugin id}
DELETE /consumers/{consumer username or id}/plugins/{plugin id}
Upstream Objects
对象实体Json Demo
1 | { |
新增
POST /upstreams/
Request json对象参数 | 0.14 | 2.0x |
---|---|---|
This is a hostname, which must be equal to the host of a Service. | name | name |
The number of slots in the loadbalancer algorithm (10-65536, defaults to 1000). | slots | slots |
What to use as hashing input: none, consumer, ip, header, or cookie (defaults to none resulting in a weighted-round-robin scheme). | hash_on | hash_on |
What to use as hashing input if the primary hash_on does not return a hash | hash_fallback | hash_fallback |
The header name to take the value from as hash input (only required when hash_on is set to header). | hash_on_header | hash_on_header |
The header name to take the value from as hash input (only required when hash_fallback is set to header). | hash_fallback_header | hash_fallback_header |
The cookie name to take the value from as hash input (only required when hash_on or hash_fallback is set to cookie) | hash_on_cookie | hash_on_cookie |
The cookie path to set in the response headers | hash_on_cookie_path | hash_on_cookie_path |
Socket timeout for active health checks (in seconds). Defaults to 1. | healthchecks.active.timeout | healthchecks.active.timeout |
Number of targets to check concurrently in active health checks. Defaults to 10 | healthchecks.active.concurrency | healthchecks.active.concurrency |
Path to use in GET HTTP request to run as a probe on active health checks. | healthchecks.active.http_path | healthchecks.active.http_path |
Interval between active health checks for healthy targets (in seconds). A value of zero indicates that active probes for healthy targets should not be performed. Defaults to 0 | healthchecks.active.healthy.interval | healthchecks.active.healthy.interval |
An array of HTTP statuses to consider a success, indicating healthiness, when returned by a probe in active health checks. Defaults to 0 | healthchecks.active.healthy.http_statuses | healthchecks.active.healthy.http_statuses |
Number of successes in active probes (as defined by healthchecks.active.healthy.http_statuses) to consider a target healthy. Defaults to 0 | healthchecks.active.healthy.successes | healthchecks.active.healthy.successes |
… | … | … |
An optional set of strings associated with the Upstream, for grouping and filtering. | tags | |
The hostname to be used as Host header when proxying requests through Kong. | host_header |
查询
GET /upstreams/{name or id}
GET /upstreams/ (offset、size可分页)
GET /upstreams/{name or id}/health/
2.0x 新增接口
GET /targets/{target host:port or id}/upstream
更新
PATCH /upstreams/{name or id}
2.0x 新增接口
PATCH /targets/{target host:port or id}/upstream
更新或者新建
PUT /upstreams/ 在2.0 修改为 PUT /upstreams/{upstream name or id}
2.0x 新增接口
PUT /targets/{target host:port or id}/upstream
删除
DELETE /upstreams/{name or id}
2.0x 新增接口
DELETE /targets/{target host:port or id}/upstream