nginx ingress IP allowlist on Azure Kubernetes Services

I have a SOLR cluster set up with a Service of type LoadBalancer to expose port 8983. A requirement is SSL termination, so I have set up an nginx ingress controller with a route through to the back end service. All of this is working as expected, however I would now like to restrict access to only certain IPs.

When I tried to use the nginx.ingress.kubernetes.io/whitelist-source-range annotation, I noticed that the requests all come from the internal IP of the node, and not from the client as expected. Does this mean traffic needs to be filtered before it gets to the AKS cluster? If so, what is the best method of doing that, as it seems like modifying the automatically-created NSG is not recommended.

Answer

To get the external IP passed through properly so you can filter it you need to set service.spec.externalTrafficPolicy field to Local in Nginx.

Attribution
Source : Link , Question Author : Owen Martin , Answer Author : Sam Cogan

Leave a Comment