BobW
BobW

Reputation: 91

Istio traffic management with nginx-ingress working but only for port 80

I've seen something strange where I've been able to have an nginx-ingress with an injected sidecar (i.e. part of the mesh) successfully route traffic that it receives into a cluster based on a k8s ingress definition, and then apply Istio traffic routing to route traffic as desired internally, but this only works when the traffic is being sent to the k8s services via port 80, and only when that is a port that is NOT served by the associated k8s service. This tells me my success is likely some kind of hack.

I'm asking if anyone can point out where I'm going wrong and/or why this is working. (I need to use the nginx ingress here, I can't switch to using istio-ingressgateway for this.)

My configuration / ability to reproduce this is documented in full on this github project: https://github.com/bob-walters/nginx-istio which I've created to provide a way to repeat this setup.

My setup:

  podAnnotations:
    traffic.sidecar.istio.io/includeInboundPorts: ""
    traffic.sidecar.istio.io/excludeInboundPorts: "80,443"

Here's the oddity:

This is what I'm seeing as I try varying the port numbers:

Target Port of Ingress Rule K8s Service Port Virtual service Port Result
80 9898 not set virtual service works as desired
9898 9898 not set routes to K8s Service. Virtual service has no effect
8080 9898 not set fails: timeout/502 while attempting to invoke service
9898 9898 9898 routes to K8s Service. Virtual service has no effect
443 9898 not set fails: timeout/502 while attempting to invoke service

I'm really confused as to why this is not working with port 9898, but is working for port 80, especially given that K8s reports my ingress definition as invalid. My understanding of the routing is that the inbound traffic would go to the 'controller' container in the nginx-ingress service, bypassing the istio proxy as long as it comes in on ports 80 or 443. The outbound traffic should all be going through the proxy destined for the ClusterIP addresses of the k8s services, but with the 'Host' header still containing the original requested host. Thus Istio should be able to handle its routing responsibilities based on Host + Port, and does so, but only if I am routing into the mesh with port 80.

Any help greatly appreciated!

Upvotes: 3

Views: 1835

Answers (1)

BobW
BobW

Reputation: 91

I struggled with this some more and eventually got it working. There are some specific (non-intuitive) things that have to be correctly lined up for virtual services to work with traffic handled by an nginx-ingress. The details are at the README.md at https://github.com/bob-walters/nginx-istio

Upvotes: 1

Related Questions