Score:0

How can i route pods in a EKS cluster to a specific NAT Gateway within the same subnet

mx flag

Am running an EKS cluster deployed on a node (in public subnet) with two namespaces, one pod running in each of the namespaces. I have created two NAT gateways on the same subnet. I would like to route egress traffic from pod A to NAT gateway A and egress traffic from pod b to NAT gateway B. Am well aware that this use case is peculiar and NAT gateways arent supposed to be used this way, but my situation calls for such a solution

My approach was to modify the pod's ip route table to add a default gateway that points to the appropriate NAT gateway's private ip. It would look something like

**For pod A**
*ip route add default via <NAT1's priv ip> dev eth0*
(Am unsure if this is even possible, how will the POD's ip namespace even know about NAT's 1 private IP)

**For pod B**
*ip route add default via <NAT2's priv ip> dev eth0*

Is there a better way to achieve routing to a specific NAT Gateway from within PODS?

Thanks Kay

Mikolaj S. avatar
cn flag
Which Kubernetes version do you have? Are you using any [CNI plugin](https://kubernetes.io/docs/concepts/extend-kubernetes/compute-storage-net/network-plugins/)?
mx flag
Am using aws vpc cni. Am open to exploring other cni as well
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.