| title | Enable a plugin on a Route | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| description | Enable a plugin on a Route in {{site.konnect_short_name}} using the KongPlugin and KongPluginBinding CRDs and configure it for use with your control plane. | |||||||||||||||
| content_type | how_to | |||||||||||||||
| permalink | /operator/konnect/crd/gateway/plugin/ | |||||||||||||||
| breadcrumbs |
|
|||||||||||||||
| products |
|
|||||||||||||||
| search_aliases |
|
|||||||||||||||
| works_on |
|
|||||||||||||||
| entities | ||||||||||||||||
| tags |
|
|||||||||||||||
| related_resources |
|
|||||||||||||||
| tldr |
|
|||||||||||||||
| prereqs |
|
In this tutorial, we'll bind a plugin to {{site.base_gateway}} entities, like a Route, using the KongPluginBinding CRD.
First, create a Gateway Service in {{site.konnect_short_name}} using the KongService CRD:
{% konnect_crd %} kind: KongService apiVersion: configuration.konghq.com/v1alpha1 metadata: name: example-service spec: name: example-service host: httpbin.konghq.com protocol: http controlPlaneRef: type: konnectNamespacedRef konnectNamespacedRef: name: gateway-control-plane {% endkonnect_crd %}
To expose the Service, create a KongRoute associated with the KongService defined previously:
{% konnect_crd %} kind: KongRoute apiVersion: configuration.konghq.com/v1alpha1 metadata: name: example-route spec: name: example-route protocols:
- http paths:
- /anything serviceRef: type: namespacedRef namespacedRef: name: example-service {% endkonnect_crd %}
In this tutorial, you'll enable a simple configuration of the Rate Limiting plugin.
First, enable the plugin:
{% konnect_crd %} kind: KongPlugin apiVersion: configuration.konghq.com/v1 metadata: namespace: kong name: rate-limiting-minute-5 plugin: rate-limiting config: policy: local minute: 5 hour: 1000 {% endkonnect_crd %}
Then, to bind the plugin to the Route, create a KongPluginBinding:
{% konnect_crd %} kind: KongPluginBinding apiVersion: configuration.konghq.com/v1alpha1 metadata: name: binding-route-example-rate-limiting spec: pluginRef: kind: KongPlugin name: rate-limiting-minute-5 targets: routeRef: group: configuration.konghq.com kind: KongRoute name: example-route controlPlaneRef: type: konnectNamespacedRef konnectNamespacedRef: name: gateway-control-plane {% endkonnect_crd %}
{% validation kubernetes-resource %} kind: KongPluginBinding name: binding-route-example-rate-limiting {% endvalidation %}