Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

NAT Pod IP to Node IP on GKE GCP or alternative solutions?

Here's my problem. My GKE GCP node IP addresses have access to an on premise network(private subnet) using ipsec/vpn and on premise firewall rules but my pod IP addresses do not. I want my traffic going from pods to use one of the acceptable node source IP addresses. How can I achieve that? I know IP masquerading is there, but will it work when my destination address is another private subnet range reachable via VPN/IPSeC ? Are there any other solution to achieve it?

Solved Solved
0 1 1,763
1 ACCEPTED SOLUTION

@ishanC 
When packets are sent to private network within VPC (or onprem connected via VPN), your cluster does not masquerade IP address sources and preserves source Pod IP addresses. 
To change this behaviour update the `ip-masq-agent` config map and under `nonMasqueradeCIDRs` remove your onprem subnet range. 
Now when the packets are send to those IP address destination, cluster will use the Node IP address

View solution in original post

1 REPLY 1

@ishanC 
When packets are sent to private network within VPC (or onprem connected via VPN), your cluster does not masquerade IP address sources and preserves source Pod IP addresses. 
To change this behaviour update the `ip-masq-agent` config map and under `nonMasqueradeCIDRs` remove your onprem subnet range. 
Now when the packets are send to those IP address destination, cluster will use the Node IP address

Top Labels in this Space
Top Solution Authors