Skip to content

Commit ca97d0d

Browse files
committed
Adding ability to disable IP-in-IP tunnelining for cross node pod-to-pod connectivity
where nodes are in different subnet. With tunneling disabled its expected that default gateway has learned the pod CIDR's allocated for all the nodes and can route the pod-to-pod traffic across nodes in different subnets Fixes #119
1 parent 1c4adaf commit ca97d0d

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

app/controllers/network_routes_controller.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ type NetworkRoutingController struct {
5454
globalPeerAsnNumber uint32
5555
bgpFullMeshMode bool
5656
podSubnetsIpSet *ipset.IPSet
57+
enableOverlays bool
5758
}
5859

5960
var (
@@ -464,6 +465,24 @@ func (nrc *NetworkRoutingController) injectRoute(path *table.Path) error {
464465
if !nrc.nodeSubnet.Contains(nexthop) {
465466
tunnelName := "tun-" + strings.Replace(nexthop.String(), ".", "", -1)
466467
glog.Infof("Found node: " + nexthop.String() + " to be in different subnet.")
468+
469+
// if overlay is not enabled then skip creating tunnels and adding route
470+
if !nrc.enableOverlays {
471+
glog.Infof("Found node: " + nexthop.String() + " to be in different subnet but overlays are " +
472+
"disabled so not creating any tunnel and injecting route for the node's pod CIDR.")
473+
glog.Infof("Cleaning up if there is any existing tunnel interface for the node")
474+
link, err := netlink.LinkByName(tunnelName)
475+
if err != nil {
476+
return nil
477+
}
478+
err = netlink.LinkDel(link)
479+
if err != nil {
480+
glog.Errorf("Failed to delete tunnel link for the node due to " + err.Error())
481+
}
482+
return nil
483+
}
484+
485+
// create ip-in-ip tunnel and inject route as overlay is enabled
467486
var link netlink.Link
468487
var err error
469488
link, err = netlink.LinkByName(tunnelName)
@@ -1007,6 +1026,8 @@ func NewNetworkRoutingController(clientset *kubernetes.Clientset,
10071026

10081027
nrc.advertiseClusterIp = kubeRouterConfig.AdvertiseClusterIp
10091028

1029+
nrc.enableOverlays = kubeRouterConfig.EnableOverlay
1030+
10101031
if (len(kubeRouterConfig.PeerRouter) != 0 && len(kubeRouterConfig.PeerAsn) == 0) ||
10111032
(len(kubeRouterConfig.PeerRouter) == 0 && len(kubeRouterConfig.PeerAsn) != 0) {
10121033
return nil, errors.New("Either both or none of the params --peer-asn, --peer-router must be specified")

app/options/options.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,15 @@ type KubeRouterConfig struct {
2929
FullMeshMode bool
3030
GlobalHairpinMode bool
3131
NodePortBindOnAllIp bool
32+
EnableOverlay bool
3233
}
3334

3435
func NewKubeRouterConfig() *KubeRouterConfig {
3536
return &KubeRouterConfig{ConfigSyncPeriod: 1 * time.Minute,
3637
IpvsSyncPeriod: 1 * time.Minute,
3738
IPTablesSyncPeriod: 1 * time.Minute,
3839
RoutesSyncPeriod: 1 * time.Minute,
40+
EnableOverlay: true,
3941
}
4042
}
4143

@@ -84,4 +86,7 @@ func (s *KubeRouterConfig) AddFlags(fs *pflag.FlagSet) {
8486
"Add iptable rules for every Service Endpoint to support hairpin traffic.")
8587
fs.BoolVar(&s.NodePortBindOnAllIp, "nodeport-bindon-all-ip", false,
8688
"For service of NodePort type create IPVS service that listens on all IP's of the node.")
89+
fs.BoolVar(&s.EnableOverlay, "enable-overlay", true,
90+
"When enable-overlay set to true, IP-in-IP tunneling is used for pod-to-pod networking across nodes in different subnets. "+
91+
"When set to false no tunneling is used and routing infrastrcture is expected to route traffic for pod-to-pod networking across nodes in different subnets")
8792
}

0 commit comments

Comments
 (0)