We run K8S cluster in private network behind firewall with nasty reverse NAT rules that prevent our hosts to connect to themselves over public IPs.
Problem
From inside a pod I need to connect to the service that is resolved to public IP 203.X.X.X
that is not possible. However I can connect to this service over private IP 192.Y.Y.Y
I can setup iptables rule on the node running pod as follows:
iptables -A OUTPUT -t nat -p tcp -d 203.X.X.X --dport 80 -j DNAT --to-destination 192.Y.Y.Y:80
Then I can successfully connect to the service from node, but not from pod running on this node.
Solution with hostAliases would not work as we:
- do not know the host names in advance
- would like to reroute all traffic to known public (unreachable) IPs to the respective private IPs
PS: We use calico as networking plugin