I have 1 deployment on ManagedKubernetes Cluster on Alibaba Cloud with service spec.type=LoadBalancer I can successfuly use that IP for incoming traffic
But the outbound ip seems still use the NAT Gateway IP for the deployment that have service spec.type=LoadBalancer
So how can I use the same IP for outgoing and incoming traffic for deployment that use LoadBalancer ?
You might find your solution here:
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=LoadBalancer
service/loadbalancer exposed
$ kubectl get svc loadbalancer
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
loadbalancer LoadBalancer 10.0.65.118 104.198.149.140 80/TCP 5m
$ curl 104.198.149.140
CLIENT VALUES:
client_address=10.240.0.5
...