@@ -10,6 +10,10 @@ import (
1010 "github.com/pkg/errors"
1111)
1212
13+ const (
14+ defaultGateway = "0.0.0.0"
15+ )
16+
1317// for AKS L1VH, do not set default route on infraNIC to avoid customer pod reaching all infra vnet services
1418// default route is set for secondary interface NIC(i.e,delegatedNIC)
1519func (k * K8sSWIFTv2Middleware ) setRoutes (podIPInfo * cns.PodIpInfo ) error {
@@ -19,7 +23,7 @@ func (k *K8sSWIFTv2Middleware) setRoutes(podIPInfo *cns.PodIpInfo) error {
1923 // TODO: Remove this once HNS fix is ready
2024 route := cns.Route {
2125 IPAddress : "0.0.0.0/0" ,
22- GatewayIPAddress : "0.0.0.0" ,
26+ GatewayIPAddress : defaultGateway ,
2327 }
2428 podIPInfo .Routes = append (podIPInfo .Routes , route )
2529
@@ -69,16 +73,15 @@ func (k *K8sSWIFTv2Middleware) addDefaultRoute(podIPInfo *cns.PodIpInfo, gateway
6973 podIPInfo .Routes = append (podIPInfo .Routes , route )
7074}
7175
76+ // add routes to podIPInfo for the given CIDRs and gateway IP
77+ // always use default gateway IP for containerd to configure routes;
78+ // containerd will set route with default gateway ip like 10.0.0.0/16 via 0.0.0.0 dev eth0
7279func (k * K8sSWIFTv2Middleware ) addRoutes (cidrs []string ) []cns.Route {
7380 routes := make ([]cns.Route , len (cidrs ))
7481 for i , cidr := range cidrs {
75- ip , _ , err := net .ParseCIDR (cidr )
76- if err != nil {
77- return nil
78- }
7982 routes [i ] = cns.Route {
8083 IPAddress : cidr ,
81- GatewayIPAddress : ip . String () ,
84+ GatewayIPAddress : defaultGateway ,
8285 }
8386 }
8487 return routes
0 commit comments