Using Kong with TriggerMesh
The Kong Ingress Controller can be configured as the network layer for TriggerMesh, enabling it to perform internal and external routing.
The steps in this article guide you through the installation and configuration process, referring to external links when information beyond this scope is needed.
Knative Serving needs to be installed on a Kubernetes cluster, follow the instructions at the documentation to install it, skipping the network layer.
Knative networking layer
Kong is a networking layer option for Knative, you don't need to install any of the other choices at the project's documentation.
This guide was written using:
- Kong Ingress Controller
Install Kong Ingress Controller
Kong Ingress Controller can be installed using either the YAML manifest at their repository or helm charts.
When using YAML, apply the provided manifest:
When using Helm follow their installation instructions.
Once Kong is installed take note of the IP address or public CNAME of the
kong-proxy service at the
In the example above the external IP address
22.214.171.124 was provisioned.
Configure Kong Network Layer For Knative
Knative Ingress Class
We will configure Knative to use
kong as the Ingress class:
Setup Knative Domain
Use the Kong Ingress external IP or CNAME to configure your the domain name resolution as explained at Knative's documentation.
Once this is done, the setup is complete.
Send a request to the configured domain and make sure that a 404 response is returned:
The 404 response is expected since we have not configured any services yet.
Deploy a Knative Service:
Wait for the service to be ready, then get it's exposed URL. The URL should be a sub-domain of the configured CNAME:
A call to the URL using a web browser or
curl should return a successful text response:
By inspecting the returned headers for the request above we can tell that it was proxied by Kong, latency headers being added to the response.
Test Kong Plugins For Knative Services
Kong supports plugins to customize knative services requests and responses.
First, let's create a KongPlugin resource:
Next, we will update the Knative service created before and add an annotation to the template:
kubectl apply -f - <<EOF
- image: gcr.io/knative-samples/helloworld-go
- name: TARGET
Note that the annotation
konghq.com/plugins is not added to the Service definition itself but to the
Let's make the request again:
curl -i http://helloworld-go.default.126.96.36.199.nip.io/
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Date: Wed, 11 May 2022 13:48:53 GMT
As we can see, the response has the
demo header injected.