TL;DR
I followed each step of the External Service tutorial, but when I try to send and HTTP request to http://localhost/httpbin/anything
, I get the "no Route matched with those values." error message.
Is the guide outdated? Is it missing some step?
Long Version
Kong Setup
I've setup Kong Gateway on a local Kubernetes cluster, with minikube:
minikube start --driver=docker
# In another terminal window/in a background process
minikube tunnel
Gateway API CRDs:
kubectl apply -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.0.0/standard-install.yaml
echo "
---
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: kong
annotations:
konghq.com/gatewayclass-unmanaged: 'true'
spec:
controllerName: konghq.com/kic-gateway-controller
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: kong
spec:
gatewayClassName: kong
listeners:
- name: proxy
port: 80
protocol: HTTP
" | kubectl apply -f -
Kong installation with helm:
helm repo add kong https://charts.konghq.com
helm repo update
helm install kong kong/ingress -n kong --create-namespace
Testing connectivity:
export PROXY_IP=$(kubectl get svc --namespace kong kong-gateway-proxy -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo $PROXY_IP
curl -i $PROXY_IP
External Service Configuration
I've consensed the Service and HTTPRoute in the same YAML:
---
# Service
kind: Service
apiVersion: v1
metadata:
name: proxy-to-httpbin
spec:
ports:
- protocol: TCP
port: 80
type: ExternalName
externalName: httpbin.org
---
# Route /httpbin
apiVersion: gateway.networking.k8s.io/v1
kind: HTTPRoute
metadata:
name: proxy-from-k8s-to-httpbin
annotations:
konghq.com/strip-path: 'true'
spec:
parentRefs:
- name: kong
rules:
- matches:
- path:
type:
value: /httpbin
backendRefs:
- name: proxy-to-httpbin
kind: Service
port: 80
and applied it:
$ kubectl apply -f ./external-service.yaml
service/proxy-to-httpbin created
httproute.gateway.networking.k8s.io/proxy-from-k8s-to-httpbin created
Result:
$ kubectl get services
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
proxy-to-httpbin ExternalName <none> httpbin.org 80/TCP 8m1s
$ kubectl get httproutes
NAME HOSTNAMES AGE
proxy-from-k8s-to-httpbin 8m51s
Problem
The guide states that after these steps, when testing the service you should get a response similiar to what you would receive from http://httpbin.org/anything.
But when I send an HTTP request to gateway-proxy/httpbin/anything, I get the "no route" error:
$ curl -s -i $PROXY_IP/httpbin/anything
HTTP/1.1 404 Not Found
Content-Type: application/json; charset=utf-8
Content-Length: 52
Connection: keep-alive
Date: Wed, 15 Nov 2023 15:58:39 GMT
X-Kong-Response-Latency: 0
Server: kong/3.4.2
X-Kong-Upstream-Latency: 9
X-Kong-Proxy-Latency: 1
Via: kong/3.4.2
{
"message":"no Route matched with those values"
}
Question
How can I make the Gateway forward correctly my HTTP requests to the external service?
Update
I deployed Kong on AKS, with the same configuration, and the external service httpbin
now does work:
curl -s -i 4.232.X.X/httpbin/anything
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 480
Connection: keep-alive
X-Cache-Key: c48fe84b97bba1516dd96c93604fc907de95cf449284992594d1325998236ffb
X-Cache-Status: Bypass
Date: Fri, 01 Dec 2023 10:22:10 GMT
Server: gunicorn/19.9.0
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
X-Kong-Upstream-Latency: 504
X-Kong-Proxy-Latency: 1
Via: kong/3.4.2
{
"args": {},
"data": "",
"files": {},
"form": {},
"headers": {
"Accept": "*/*",
"Host": "4.232.X.X",
"User-Agent": "curl/8.2.1",
"X-Amzn-Trace-Id": "Root=1-6569b3d1-7a71e89914522ebe73d9d548",
"X-Forwarded-Host": "4.232.X.X",
"X-Forwarded-Path": "/httpbin/anything",
"X-Forwarded-Prefix": "/httpbin/"
},
"json": null,
"method": "GET",
"origin": "10.224.0.4, 4.232.X.Y",
"url": "http://4.232.X.X/anything"
}
So I guess this might have something to do with minikube