I'm trying to set up Kong as an API gateway in my Kubernetes cluster. I have a service named quick-links-service running in the default namespace, and I want to install Kong in the kong namespace to route requests to this service. Here's the YAML for my Ingress resource:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: quick-links-ingress
annotations:
konghq.com/strip-path: 'true'
spec:
ingressClassName: kong
rules:
- host: kong.example
http:
paths:
- path: /quick-links
pathType: Prefix
backend:
service:
name: quick-links-service
port:
number: 3000
I've tried installing Kong using Helm in the kong namespace with the following command:
helm install kong kong/kong --namespace kong --set admin.useTLS=false,admin.enabled=true,admin.http.enabled=true
I forwarded port of the kong pod:
kubectl port-forward kong-kong-b7f7889d-mwlf9 -n kong 8001:8001
When I hit http://localhost:80001/services, I get below response:
{
"next": null,
"data": [
{
"id": "0061fec8-7d38-5786-aa81-4174caf13e05",
"enabled": true,
"write_timeout": 60000,
"tls_verify": null,
"name": "default.quick-links-service.3000",
"retries": 5,
"path": "/",
"port": 3000,
"tags": [
"k8s-name:quick-links-service",
"k8s-namespace:default",
"k8s-kind:Service",
"k8s-uid:c5065699-bbef-41ba-a495-a6b643021da6",
"k8s-version:v1"
],
"ca_certificates": null,
"client_certificate": null,
"protocol": "http",
"connect_timeout": 60000,
"created_at": 1708140855,
"read_timeout": 60000,
"tls_verify_depth": null,
"host": "quick-links-service.default.3000.svc",
"updated_at": 1708140855
}
]
}
However, I'm having trouble configuring Kong to route requests to the quick-links-service.
How can I properly configure Kong and the Ingress resource to achieve this and access quick-links using kong locally?
When you have more than one ingress controller and Kong is not the default, you should use Kong CRD to specify it's configuration.
Kong ingress controller provides a Custom Resource Definition
KongIngressto define Kong specific configuration properties: