kubernetes - egress traffic - whats is the source IP for receiving ingress traffic (how to check) - Need to randomize

1.2k Views Asked by At
  • My Setup GKE / EKS - Managed Kubernetes Cluster

  • As of now for Business requirements, it is k8s cluster with Public Endpoints

  • What it means is that I have a Public endpoint for API Server as well Nodes have an External Public IP Address

  • nginx ingress is deployed for route-based traffic and exposed as a Loadbalancer type

  • And The LoadBalancer is of type Network Load Balancer internet facing(Or External) having a Public IP Address (say 35.200.24.99)

    My requirement or I want to understand, is this

  • If my Pod makes a call to the outside APIs, what will be the source IP that the outside API will receive? Is it my LoadBalencer IP or the Pod Node External IP Address

  • If it receives the LB IP, is there a way to change this behavior to send the Pod Node IP Address?

  • Also is there any tool or a way to simulate what is the Source IP, I am getting while Pod makes a request to an outside API

  1. I could not try out anything
  2. I tried hitting curl requests to nginx Pod that wsa running inside, but did not get desired results or I could not figure out
1

There are 1 best solutions below

4
On

If my Pod makes a call to the outside APIs, what will be the source IP that the outside API will receive? Is it my LoadBalencer IP or the Pod Node External IP Address

It your POD sending request and your cluster is public it will be Node's IP on which POD is running/scheduled.

If it receives the LB IP, is there a way to change this behavior to send the Pod Node IP Address?

it wont get the LB IP, it will be Node's IP only on which POD is running. If you want to manage the Single outgoing IP you can use the NAT gateway so all traffic will go out of the single source IP.

Also is there any tool or a way to simulate what is the Source IP, I am getting while Pod makes a request to an outside API

Go to the POD using kubectl exec -it <POD name> bash once you are inside the POD run the curl ifconfig.me it will return the IP from which you are hitting the site. Mostly it will be Node's IP.

Consider ifconfig.me as an outside API and you will get your result.