Hi,
I’am having trouble configuring kong ingress controller in kubernetes. I would like to route traffic based on a request header to a service in my kubernetes cluster. The host of these request should be the same.
The request curl -X POST http://myhost.com -H 'x-custom-header: some-value'
should be routed to serviceA and curl -X POST http://myhost.com -H 'x-custom-header: some-other-value'
should be routed to serviceB.
Ingress only support path and host based routing and I can’t figure out how I should configure my ingress. This is my current configuration.
Ingress:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: api-gateway-ingress
spec:
- host: myhost.com
http:
paths:
- path: /
backend:
serviceName: serviceA
servicePort: 80
- path: /b
backend:
serviceName: serviceB
servicePort: 80
Service:
apiVersion: v1
kind: Service
metadata:
name: serviceA
annotations:
configuration.konghq.com: service-a-routing
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
---
apiVersion: v1
kind: Service
metadata:
name: serviceB
annotations:
configuration.konghq.com: service-b-routing
spec:
type: ClusterIP
ports:
- port: 80
targetPort: http
protocol: TCP
name: http
KongIngress:
apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
name: service-a-routing
route:
hosts:
- myhost.com
headers:
x-custom-header:
- some-value
---
apiVersion: configuration.konghq.com/v1
kind: KongIngress
metadata:
name: service-b-routing
route:
hosts:
- myhost.com
headers:
x-custom-header:
- some-other-value
When I make the request curl -X POST http://myhost.com -H 'x-custom-header: some-other-value'
it is routed to serviceA instead of serviceB.
Any recommendation?
Thanks,
Tom