Skip to content

Commit

Permalink
handle environments without direct connectivity
Browse files Browse the repository at this point in the history
Change-Id: I62dc89af231745b9af61a8f071734e6f02804c44
  • Loading branch information
aojea committed Sep 6, 2024
1 parent 224ce09 commit d63cc5d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion cmd/kindnetd/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,24 @@ import (

func syncRoute(nodeIP string, podCIDRs []string) error {
ip := net.ParseIP(nodeIP)

mask := net.CIDRMask(32, 32)
if ip.To4() == nil {
mask = net.CIDRMask(128, 128)
}
// check if nodeIP is reachable, this happens when nodes are in the same l2 domain
// Environments like GCE implement IP alias, and assign /24 to the VMs so there is
// no l2 domain for the instances, and the traffic is handled by the underneath SDN
routeToNode := netlink.Route{Dst: &net.IPNet{IP: ip, Mask: mask}}
routes, err := netlink.RouteListFiltered(nl.GetIPFamily(ip), &routeToNode, netlink.RT_FILTER_DST)
if err != nil {
return err
}
for _, route := range routes {
if route.Gw != nil {
klog.Infof("Route to Node %s via %s, no direct routing needed, if pods can not communicate please configure your router correctly", ip, route.Gw.String())
return nil
}
}
for _, podCIDR := range podCIDRs {
// parse subnet
dst, err := netlink.ParseIPNet(podCIDR)
Expand Down

0 comments on commit d63cc5d

Please sign in to comment.