Skip to content

Commit

Permalink
fix: remove svc cidr routes
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Nov 27, 2020
1 parent ceca00a commit f535460
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions pkg/daemon/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ func (c *Controller) reconcileRouters() error {
klog.Errorf("failed to list namespace %v", err)
return err
}
cidrs := make([]string, 0, len(subnets)+1)
cidrs = append(cidrs, c.config.ServiceClusterIPRange)
cidrs := make([]string, 0, len(subnets))
for _, subnet := range subnets {
if !subnet.Status.IsReady() || subnet.Spec.UnderlayGateway {
continue
Expand Down Expand Up @@ -243,14 +242,8 @@ func (c *Controller) reconcileRouters() error {
_, cidr, _ := net.ParseCIDR(r)
gw := net.ParseIP(gateway)
src := net.ParseIP(c.internalIP)
if r == c.config.ServiceClusterIPRange {
if err = netlink.RouteReplace(&netlink.Route{Dst: cidr, LinkIndex: nic.Attrs().Index, Scope: netlink.SCOPE_UNIVERSE, Gw: gw}); err != nil {
klog.Errorf("failed to add route %v", err)
}
} else {
if err = netlink.RouteReplace(&netlink.Route{Dst: cidr, LinkIndex: nic.Attrs().Index, Scope: netlink.SCOPE_UNIVERSE, Gw: gw, Src: src}); err != nil {
klog.Errorf("failed to add route %v", err)
}
if err = netlink.RouteReplace(&netlink.Route{Dst: cidr, LinkIndex: nic.Attrs().Index, Scope: netlink.SCOPE_UNIVERSE, Gw: gw, Src: src}); err != nil {
klog.Errorf("failed to add route %v", err)
}
}
return err
Expand Down

0 comments on commit f535460

Please sign in to comment.