How to use LoadBalancer IP as the outgoing / outbound / egress IP of the pods How to use LoadBalancer IP as the outgoing / outbound / egress IP of the pods kubernetes kubernetes

How to use LoadBalancer IP as the outgoing / outbound / egress IP of the pods


You might find your solution here:

https://kubernetes.io/docs/tutorials/services/source-ip/#source-ip-for-services-with-type-loadbalancer

As of Kubernetes 1.5, packets sent to Services with Type=LoadBalancer are source NAT’d by default because all schedulable Kubernetes nodes in the Ready state are eligible for load-balanced traffic. So if packets arrive at a node without an endpoint, the system proxies it to a node with an endpoint, replacing the source IP on the packet with the IP of the node (as described in the previous section).You can test this by exposing the source-ip-app through a loadbalancer

$ kubectl expose deployment source-ip-app --name=loadbalancer --port=80 --target-port=8080 --type=LoadBalancerservice/loadbalancer exposed$ kubectl get svc loadbalancerNAME           TYPE           CLUSTER-IP    EXTERNAL-IP       PORT(S)   AGEloadbalancer   LoadBalancer   10.0.65.118   104.198.149.140   80/TCP    5m$ curl 104.198.149.140CLIENT VALUES:client_address=10.240.0.5...