Kong
Features
Ingress routing Use Ingress resources to configure Kong.
Enhanced API management using plugins Use a wide array of plugins to monitor, transform and protect your traffic.
Native gRPC support Proxy gRPC traffic and gain visibility into it using Kong's plugins.
Health checking and Load-balancing Load balance requests across your pods and supports active & passive health-checks.
Request/response transformations Use plugins to modify your requests/responses on the fly.
Authentication Protect your services using authentication methods of your choice.
Declarative configuration for Kong Configure all of Kong using CRDs in Kubernetes and manage Kong declaratively.
Gateway Discovery Monitors your Kong Gateways and pushes configuration to all replicas.
Setting up Kong for Kubernetes is as simple as:
Once installed, set an environment variable, $PROXY_IP with the External IP address of the demo-kong-proxy
service in kong
namespace:
Testing connectivity to Kong Gateway
This guide assumes that PROXY_IP
environment variable is set to contain the IP address or URL pointing to Kong Gateway. If you’ve not done so, follow one of the deployment guides to configure this environment variable.
If everything is setup correctly, making a request to Kong Gateway should return back a HTTP 404 Not Found
status code:
Response:
This is expected since Kong Gateway doesn’t know how to proxy the request yet.
Deploy an upstream HTTP application
To proxy requests, you need an upstream application to proxy to. Deploying this echo server provides a simple application that returns information about the Pod it’s running in:
Response:
Create a configuration group
Ingress and Gateway APIs controllers need a configuration that indicates which set of routing configuration they should recognize. This allows multiple controllers to coexist in the same cluster. Before creating individual routes, you need to create a class configuration to associate routes with:
IngressGateway APIs
Official distributions of Kong Ingress Controller come with a kong
IngressClass by default. If kubectl get ingressclass kong
does not return a not found
error, you can skip this command.
Response:
Kong Ingress Controller recognizes the kong
IngressClass and konghq.com/kic-gateway-controller
GatewayClass by default. Setting the CONTROLLER_INGRESS_CLASS
or CONTROLLER_GATEWAY_API_CONTROLLER_NAME
environment variable to another value overrides these defaults.
Add routing configuration
Create routing configuration to proxy /echo
requests to the echo server:
IngressGateway APIs
Response:
Test the routing rule:
Response:
If everything is deployed correctly, you should see the above response. This verifies that Kong Gateway can correctly route traffic to an application running inside Kubernetes.
Add TLS configuration
The routing configuration can include a certificate to present when clients connect over HTTPS. This is not required, as Kong Gateway will serve a default certificate if it cannot find another, but including TLS configuration along with routing configuration is typical.
First, create a test certificate for the kong.example
hostname using one of the following commands:
OpenSSL 1.1.1OpenSSL 0.9.8
Response:
Older OpenSSL versions, including the version provided with OS X Monterey, require using the alternative version of this command.
Then, create a Secret containing the certificate:
Response:
Finally, update your routing configuration to use this certificate:
IngressGateway APIs
Response:
After, requests will serve the configured certificate:
Response:
Using plugins in Kong
Setup a KongPlugin resource:
Response:
Update your route configuration to use the new plugin:
IngressGateway APIs
Response:
Requests that match the echo
Ingress or HTTPRoute now include a my-request-id
header with a unique ID in both their request headers upstream and their response headers downstream.
Using plugins on Services
Kong can also apply plugins to Services. This allows you execute the same plugin configuration on all requests to that Service, without configuring the same plugin on multiple Ingresses.
Create a KongPlugin resource:
Response:
Next, apply the konghq.com/plugins
annotation to the Kubernetes Service that needs rate-limiting:
Response:
Kong will now enforce a rate limit to requests proxied to this Service:
Response:
Last updated