Kong Gateway is designed around an extensible plugin architecture and comes with a wide variety of plugins already bundled inside it. These plugins can be used to modify the request or impose restrictions on the traffic.
Once this resource is created, the resource needs to be associated with an Ingress, Service, HTTPRoute, KongConsumer or KongConsumerGroup resource in Kubernetes.
This diagram shows how you can link a KongPlugin resource to an Ingress, Service, or KongConsumer.
flowchart TD
subgraph Link to consumer
direction TB
E(apiVersion: configuration.konghq.com/v1<br>kind: KongPlugin<br>metadata:<br> name: custom-api-limit<br>plugin: rate-limiting<br>config:<br> minute: 10):::left
F(apiVersion: configuration.konghq.com<br>kind: KongConsumer<br>metadata:<br> name: demo-api<br> annotations:<br> konghq.com/plugins: custom-api-limit<br>username: special-client):::left
end
subgraph Link to Ingress and service
direction TB
A(apiVersion: configuration.konghq.com/v1<br>kind: KongPlugin<br>metadata:<br> name: reports-api-limit<br>plugin: rate-limiting<br>config: <br> minute: 5):::left
B(apiVersion: extensions/v1beta1<br>kind: Ingress<br>metadata:<br> name: demo-api<br> annotations:<br> konghq.com/plugins: reports-api-limit):::left
C(apiVersion: v1<br>kind: Service<br>metadata:<br> name: billing-api<br> annotations:<br> konghq.com/plugins: billing-auth):::left
D(apiVersion: configuration.konghq.com/v1<br>kind: KongPlugin<br>metadata:<br> name: billing-auth<br>plugin: basic auth):::left
end
A --> |execute the plugin for any request that matches a rule in the following ingress resource|B
B --> C
D --> |execute the plugin for any request that is forwarded to the billing-api service in k8s|C
E --> |Associated using konghq.com/plugins annotation|F