How to configure Kubenetes to make external requests going from a static IP
If you're on AWS or GKE the only way to get a static outbound from an (autoscaling) node pool is via a NAT gateway. On GKE you are also required to have private nodes (no public ips).
Kubernetes ingress, at least in GKE, is treated separately from egress and is a different load balancer.
Some research showed me the following method and it worked:
Create a new node pool with a specific label (lets say
ip=static
)Deploy the workload with the following selector
nodeSelector: ip: static
Through VPC Network, reserve an external static IP
Assign this IP to the VM which is used by the new node pool
However, as the @user578582 has mentioned, when the scaling is done, I will have to use a NAT gateway to make all the outbound traffic to go from a static IP under this configuration.