Introduction to Kong Plugins
Last updated
Last updated
Kong Gateway is a Lua application designed to load and execute Lua or Go modules, which we commonly refer to as plugins. Kong provides a set of standard Lua plugins that get bundled with Kong Gateway and Konnect. The set of plugins you have access to depends on your license tier.
Custom plugins can also be developed by the Kong Community and are supported and maintained by the plugin creators. If they are published on the Kong Plugin Hub, they are called Community or Third-Party plugins
Plugins provide advanced functionality and extend the use of the Kong Gateway, which allows you to add new features to your implementation. Plugins can be configured to run in a variety of contexts, ranging from a specific route to all upstreams, and can execute actions inside Kong before or after a request has been proxied to the upstream API, as well as on any incoming responses.
A single plugin instance always runs once per request. The configuration with which it runs depends on the entities it has been configured for. Plugins can be configured for various entities, combinations of entities, or even globally. This is useful, for example, when you want to configure a plugin a certain way for most requests, but make authenticated requests behave slightly differently.
Therefore, there is an order of precedence for running a plugin when it has been applied to different entities with different configurations. The amount of entities configured to a specific plugin directly correlate to its priority. The more entities configured to a plugin the higher its order of precedence is.
Plugins configured on a combination of a consumer, a route, and a service. (Consumer means the request must be authenticated).
Plugins configured on a combination of a consumer group, service, and a route. (Consumer group means the request must be authenticated).
Plugins configured on a combination of a consumer and a route. (Consumer means the request must be authenticated).
Plugins configured on a combination of a consumer and a service.
Plugins configured on a consumer group and route.
Plugins configured on a consumer group and service.
Plugins configured on a route and service.
Plugins configured on a consumer.
Plugins configured on a consumer group.
Plugins configured on a route.
Plugins configured on a service.
Plugins configured globally.
Kong provides an entire development environment for developing plugins, including Lua and Go SDKs, database abstractions, migrations, and more.
Plugins consist of modules interacting with the request/response objects or streams via a Plugin Development Kit (or PDK) to implement arbitrary logic. Kong provides PDKs for two languages: Lua and Go. Both of these PDKs are sets of functions that a plugin can use to facilitate interactions between plugins and the core (or other components) of Kong.