2525const (
2626 prefixLength = 32
2727 overlayGatewayv4 = "169.254.1.1"
28+ virtualGW = "169.254.2.1"
2829 overlayGatewayV6 = "fe80::1234:5678:9abc"
2930)
3031
@@ -56,7 +57,7 @@ func (m *SWIFTv2Middleware) SetMTPNCReady() {
5657func (m * SWIFTv2Middleware ) SetEnvVar () {
5758 os .Setenv (configuration .EnvPodCIDRs , "10.0.1.10/24" )
5859 os .Setenv (configuration .EnvServiceCIDRs , "10.0.2.10/24" )
59- os .Setenv (configuration .EnvNodeCIDRs , "10.0.3.10/24" )
60+ os .Setenv (configuration .EnvInfraVNETCIDRs , "10.0.3.10/24" )
6061}
6162
6263func (m * SWIFTv2Middleware ) UnsetEnvVar () error {
@@ -66,8 +67,8 @@ func (m *SWIFTv2Middleware) UnsetEnvVar() error {
6667 if err := os .Unsetenv (configuration .EnvServiceCIDRs ); err != nil {
6768 return fmt .Errorf ("failed to unset env var %s : %w" , configuration .EnvServiceCIDRs , err )
6869 }
69- if err := os .Unsetenv (configuration .EnvNodeCIDRs ); err != nil {
70- return fmt .Errorf ("failed to unset env var %s : %w" , configuration .EnvNodeCIDRs , err )
70+ if err := os .Unsetenv (configuration .EnvInfraVNETCIDRs ); err != nil {
71+ return fmt .Errorf ("failed to unset env var %s : %w" , configuration .EnvInfraVNETCIDRs , err )
7172 }
7273 return nil
7374}
@@ -130,20 +131,24 @@ func (m *SWIFTv2Middleware) SetRoutes(podIPInfo *cns.PodIpInfo) error {
130131 podIPInfo .Routes = []cns.Route {}
131132 switch podIPInfo .NICType {
132133 case cns .DelegatedVMNIC :
134+ virtualGWRoute := cns.Route {
135+ IPAddress : fmt .Sprintf ("%s/%d" , virtualGW , prefixLength ),
136+ }
133137 // default route via SWIFT v2 interface
134138 route := cns.Route {
135- IPAddress : "0.0.0.0/0" ,
139+ IPAddress : "0.0.0.0/0" ,
140+ GatewayIPAddress : virtualGW ,
136141 }
137- podIPInfo .Routes = []cns.Route {route }
142+ podIPInfo .Routes = []cns.Route {virtualGWRoute , route }
138143 case cns .InfraNIC :
139- // Get and parse nodeCIDRs from env
140- nodeCIDRs , err := configuration .NodeCIDRs ()
144+ // Get and parse infraVNETCIDRs from env
145+ infraVNETCIDRs , err := configuration .InfraVNETCIDRs ()
141146 if err != nil {
142- return errors .Wrapf (err , "failed to get nodeCIDR from env" )
147+ return errors .Wrapf (err , "failed to get infraVNETCIDRs from env" )
143148 }
144- nodeCIDRsv4 , nodeCIDRsv6 , err := utils .ParseCIDRs (nodeCIDRs )
149+ infraVNETCIDRsv4 , infraVNETCIDRsv6 , err := utils .ParseCIDRs (infraVNETCIDRs )
145150 if err != nil {
146- return errors .Wrapf (err , "failed to parse nodeCIDRs " )
151+ return errors .Wrapf (err , "failed to parse infraVNETCIDRs " )
147152 }
148153
149154 // Get and parse podCIDRs from env
@@ -187,13 +192,13 @@ func (m *SWIFTv2Middleware) SetRoutes(podIPInfo *cns.PodIpInfo) error {
187192 }
188193 podIPInfo .Routes = append (podIPInfo .Routes , serviceCIDRv4Route )
189194 }
190- // route for IPv4 nodeCIDR traffic
191- for _ , nodeCIDRv4 := range nodeCIDRsv4 {
192- nodeCIDRv4Route := cns.Route {
193- IPAddress : nodeCIDRv4 ,
195+ // route for IPv4 infraVNETCIDR traffic
196+ for _ , infraVNETCIDRsv4 := range infraVNETCIDRsv4 {
197+ infraVNETCIDRsv4Route := cns.Route {
198+ IPAddress : infraVNETCIDRsv4 ,
194199 GatewayIPAddress : overlayGatewayv4 ,
195200 }
196- podIPInfo .Routes = append (podIPInfo .Routes , nodeCIDRv4Route )
201+ podIPInfo .Routes = append (podIPInfo .Routes , infraVNETCIDRsv4Route )
197202 }
198203 } else {
199204 // routes for IPv6 podCIDR traffic
@@ -212,13 +217,13 @@ func (m *SWIFTv2Middleware) SetRoutes(podIPInfo *cns.PodIpInfo) error {
212217 }
213218 podIPInfo .Routes = append (podIPInfo .Routes , serviceCIDRv6Route )
214219 }
215- // route for IPv6 nodeCIDR traffic
216- for _ , nodeCIDRv6 := range nodeCIDRsv6 {
217- nodeCIDRv6Route := cns.Route {
218- IPAddress : nodeCIDRv6 ,
220+ // route for IPv6 infraVNETCIDR traffic
221+ for _ , infraVNETCIDRv6 := range infraVNETCIDRsv6 {
222+ infraVNETCIDRv6Route := cns.Route {
223+ IPAddress : infraVNETCIDRv6 ,
219224 GatewayIPAddress : overlayGatewayV6 ,
220225 }
221- podIPInfo .Routes = append (podIPInfo .Routes , nodeCIDRv6Route )
226+ podIPInfo .Routes = append (podIPInfo .Routes , infraVNETCIDRv6Route )
222227 }
223228 }
224229 podIPInfo .SkipDefaultRoutes = true
0 commit comments