
Kong is a service that sits between a client and a server, such as a web server, an application server, an FTP server. For example, let's say you want to route requests to www.example.com through Kong. In this scenario, you could create a route and a service that would be used to route requests onto www.example.com.
This assumes Kong has been secured with Role Based Access Control (RBAC) and you have created your Kong-Admin-Token. The following curl command can be used to list the endpoints that can be used with the API.
curl --header "Kong-Admin-Token: abc123" --request GET "https://kong.example.com/endpoints"
Something like this should be returned.
{
"data": [
"/",
"/acls",
"/acls/{acls}",
"/acls/{acls}/consumer",
"/plugins",
"/plugins/enabled",
"/plugins/schema/{name}",
"/plugins/{plugins}",
"/plugins/{plugins}/consumer",
"/plugins/{plugins}/route",
"/plugins/{plugins}/service",
"/routes/{routes}/plugins",
"/routes/{routes}/plugins/{plugins}",
"/services/{services}/plugins",
"/services/{services}/plugins/{plugins}"
]
}
In this example, the plugins being used by my-service in my-workspace will be listed.
curl --header "Kong-Admin-Token: abc123" --request GET "https://kong.example.com/my-workspace/services/my-service/plugins"
In this example, the plugins being used by my-route in my-workspace will be listed.
curl --header "Kong-Admin-Token: abc123" --request GET "https://kong.example.com/my-workspace/routes/my-route/plugins"
If there are no plugins, something like this should be returned.
{
"data": [],
"next": null
}
If one or more plugins exist, something like this should be returned.
{
"data": [
{
"config": {
"some_key": "some_value"
},
"consumer": null,
"created_at": 1629232358,
"enabled": true,
"id": "8a46f5f5-08e6-498f-9e6b-48d13fd13dea",
"name": "openid-connect",
"route": {
"id": "b39d8ce5-eeb2-4100-967c-0ea256fb038a"
},
"service": null,
"tags": null
}
],
"next": null
}
The date command can be used to convert the created_at epoch strings to human readable output.
~]$ date -d @1629232358
Tue Aug 17 15:32:38 CDT 2021
Postgres
Undeneath the hood, the plugins are stored in the plugins table in the Kong Postgres database.
~]# psql --username postgres --dbname kong --command "select * from plugins" --expanded
-[ RECORD 1 ]-
id | 7afe1119-04ad-4842-8ad2-6e628d78abea
name | udp-log
api_id |
consumer_id |
config | {"host": "my-route.svc", "port": 514, "timeout": 1000}
enabled | t
created_at | 2021-02-26 17:34:00+00
route_id |
service_id |
cache_key | plugins:udp-log:::::36b392d4-d823-4d50-a895-9634d1db6a76
protocols | {grpc,grpcs,http,https}
tags |
ws_id | 36b392d4-d823-4d50-a895-9634d1db6a76
Did you find this article helpful?
If so, consider buying me a coffee over at