Search code examples
azurekubernetesnginxroutesnginx-ingress

How to route traffic with if condition based on source IP addresses in NGINX Ingress Controllers


I have deployed a simple application in two Kubernetes clusters. The clusters reside in EU and US regions. The users must connect to the service through abc.com (Example) URL. The users/requests are coming from our internal network. The source IP address ranges are known. How can we route to the correct cluster based on the source IP ranges? For example requests coming from IP range 10.0.0.0/16 should route to the EU kubernetes cluster. What solution is the most suitable for this? We're using Azure and I tried Azure Traffic Manager. But it only works with public endpoints. So it doesn't suit our scenario. Can we add an 'if' condition based on the source IP ranges in the Ingress rules and route traffic to the correct Kubernetes cluster?


Solution

  • as discussed in the comments:

    You can use Traffic Manager also for internal endpoints, you just can't use health probing for them. Use Always serve for this scenario.

    Also, you should be able to use subnet-based routing.