'How can I set static Egress IP for a pod?

Shortly, there are two services that communicates with each others via HTTP REST APIs. My deployment is running in an AKS cluster. For ingress controller, I installed this Nginx controller helm chart: https://kubernetes.github.io/ingress-nginx

The load balancer has a fix IP attached. My deployment running in my cluster should send usage info to the other service periodically and vica versa. However, that service has an IP whitelist and I need to provide a static IP for whitelisting my deployment. Currently, the problem is that my cURL call has the node's IP which is always changing depending on which node my deployment is running on. Also, the number of nodes are scaled dinamically, too. My goal is to send egress traffic through the loadbalancer something like this:
enter image description here

Is there any way to route the outbound traffic from my pods to the loadbalancer?



Solution 1:[1]

This is possible with Azure Load Balancer with outbound rules; which the LB will do a SNAT and your "other service" will see the fixed frontend public IP. Another method is use Virtual Network NAT where your "other service" will see the fixed NAT public IP. You can then whitelist the fixed public IP either way.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gohm'c