Skip to content

Commit

Permalink
Use --overlay-type={subnet,full} instead of --full-overlay={true,false}
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmundim committed Mar 15, 2019
1 parent 3e91536 commit d9a6367
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ Usage of kube-router:
--enable-overlay When enable-overlay is set to true, IP-in-IP tunneling is used for pod-to-pod networking across nodes in different subnets. When set to false no tunneling is used and routing infrastructure is expected to route traffic for pod-to-pod networking across nodes in different subnets (default true)
--enable-pod-egress SNAT traffic from Pods to destinations outside the cluster. (default true)
--enable-pprof Enables pprof for debugging performance and memory leak issues.
--full-overlay When full-overlay is set to true, it changes "--enable-overlay=true" default behavior so that IP-in-IP tunneling is used for pod-to-pod networking across nodes regardless of the subnet the nodes are in. When set to false, the default, default "--enable-overlay=true" behavior is used
--hairpin-mode Add iptables rules for every Service Endpoint to support hairpin traffic.
--health-port uint16 Health check port, 0 = Disabled (default 20244)
-h, --help Print usage information.
Expand All @@ -66,6 +65,7 @@ Usage of kube-router:
--metrics-port uint16 Prometheus metrics port, (Default 0, Disabled)
--nodeport-bindon-all-ip For service of NodePort type create IPVS service that listens on all IP's of the node.
--nodes-full-mesh Each node in the cluster will setup BGP peering with rest of the nodes. (default true)
--overlay-type string Possible values: subnet,full - When set to "subnet", the default, default "--enable-overlay=true" behavior is used. When set to "full", it changes "--enable-overlay=true" default behavior so that IP-in-IP tunneling is used for pod-to-pod networking across nodes regardless of the subnet the nodes are in. (default "subnet")
--override-nexthop Override the next-hop in bgp routes sent to peers with the local ip.
--peer-router-asns uints ASN numbers of the BGP peer to which cluster nodes will advertise cluster ip and node's pod cidr. (default [])
--peer-router-ips ipSlice The ip address of the external router to which all nodes will peer and advertise the cluster ip and pod cidr's. (default [])
Expand Down
12 changes: 6 additions & 6 deletions pkg/controllers/routing/network_routes_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ type NetworkRoutingController struct {
bgpGracefulRestart bool
ipSetHandler *utils.IPSet
enableOverlays bool
fullOverlay bool
overlayType string
peerMultihopTTL uint8
MetricsEnabled bool
bgpServerStarted bool
Expand Down Expand Up @@ -414,8 +414,8 @@ func (nrc *NetworkRoutingController) injectRoute(path *table.Path) error {
tunnelName := generateTunnelName(nexthop.String())
sameSubnet := nrc.nodeSubnet.Contains(nexthop)

// cleanup route and tunnel if overlay is disabled or node is in same subnet and full overlay is disabled
if !nrc.enableOverlays || (sameSubnet && !nrc.fullOverlay) {
// cleanup route and tunnel if overlay is disabled or node is in same subnet and overlay-type is set to 'subnet'
if !nrc.enableOverlays || (sameSubnet && nrc.overlayType == "subnet") {
glog.Infof("Cleaning up old routes if there are any")
routes, err := netlink.RouteListFiltered(nl.FAMILY_ALL, &netlink.Route{
Dst: dst, Protocol: 0x11,
Expand All @@ -438,9 +438,9 @@ func (nrc *NetworkRoutingController) injectRoute(path *table.Path) error {
}
}

// create IPIP tunnels only when node is not in same subnet or full overlay is true
// create IPIP tunnels only when node is not in same subnet or overlay-type is set to 'full'
// prevent creation when --override-nexthop=true as well
if (!sameSubnet || nrc.fullOverlay) && !nrc.overrideNextHop {
if (!sameSubnet || nrc.overlayType == "full") && !nrc.overrideNextHop {
// create ip-in-ip tunnel and inject route as overlay is enabled
var link netlink.Link
var err error
Expand Down Expand Up @@ -930,7 +930,7 @@ func NewNetworkRoutingController(clientset kubernetes.Interface,
nrc.advertiseLoadBalancerIP = kubeRouterConfig.AdvertiseLoadBalancerIp
nrc.advertisePodCidr = kubeRouterConfig.AdvertiseNodePodCidr
nrc.enableOverlays = kubeRouterConfig.EnableOverlay
nrc.fullOverlay = kubeRouterConfig.FullOverlay
nrc.overlayType = kubeRouterConfig.OverlayType

nrc.bgpPort = kubeRouterConfig.BGPPort

Expand Down
10 changes: 6 additions & 4 deletions pkg/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type KubeRouterConfig struct {
EnablePodEgress bool
EnablePprof bool
FullMeshMode bool
FullOverlay bool
OverlayType string
GlobalHairpinMode bool
HealthPort uint16
HelpRequested bool
Expand Down Expand Up @@ -66,6 +66,7 @@ func NewKubeRouterConfig() *KubeRouterConfig {
IPTablesSyncPeriod: 5 * time.Minute,
RoutesSyncPeriod: 5 * time.Minute,
EnableOverlay: true,
OverlayType: "subnet",
}
}

Expand Down Expand Up @@ -138,9 +139,10 @@ func (s *KubeRouterConfig) AddFlags(fs *pflag.FlagSet) {
fs.BoolVar(&s.EnableOverlay, "enable-overlay", true,
"When enable-overlay is set to true, IP-in-IP tunneling is used for pod-to-pod networking across nodes in different subnets. "+
"When set to false no tunneling is used and routing infrastructure is expected to route traffic for pod-to-pod networking across nodes in different subnets")
fs.BoolVar(&s.FullOverlay, "full-overlay", false,
"When full-overlay is set to true, it changes \"--enable-overlay=true\" default behavior so that IP-in-IP tunneling is used for pod-to-pod networking across nodes regardless of the subnet the nodes are in. "+
"When set to false, the default, default \"--enable-overlay=true\" behavior is used")
fs.StringVar(&s.OverlayType, "overlay-type", s.OverlayType,
"Possible values: subnet,full - "+
"When set to \"subnet\", the default, default \"--enable-overlay=true\" behavior is used. "+
"When set to \"full\", it changes \"--enable-overlay=true\" default behavior so that IP-in-IP tunneling is used for pod-to-pod networking across nodes regardless of the subnet the nodes are in.")
fs.StringSliceVar(&s.PeerPasswords, "peer-router-passwords", s.PeerPasswords,
"Password for authenticating against the BGP peer defined with \"--peer-router-ips\".")
fs.BoolVar(&s.EnablePprof, "enable-pprof", false,
Expand Down

0 comments on commit d9a6367

Please sign in to comment.