Skip to content

Commit

Permalink
add --enable-ibgp flag (#227)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsykim authored and murali-reddy committed Nov 27, 2017
1 parent bca4221 commit 2685367
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
15 changes: 10 additions & 5 deletions app/controllers/network_routes_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ type NetworkRoutingController struct {
globalPeerRouters []*config.NeighborConfig
nodePeerRouters []string
bgpFullMeshMode bool
bgpEnableInternal bool
bgpGracefulRestart bool
ipSetHandler *utils.IPSet
enableOverlays bool
Expand Down Expand Up @@ -267,8 +268,9 @@ func (nrc *NetworkRoutingController) Run(stopCh <-chan struct{}, wg *sync.WaitGr
glog.Errorf("Error adding BGP export policies: %s", err.Error())
}

// add the current set of nodes (excluding self) as BGP peers. Nodes form full mesh
nrc.syncPeers()
if nrc.bgpEnableInternal {
nrc.syncInternalPeers()
}

select {
case <-stopCh:
Expand Down Expand Up @@ -924,11 +926,11 @@ func (nrc *NetworkRoutingController) syncNodeIPSets() error {
return nil
}

// Refresh the peer relationship rest of the nodes in the cluster. Node add/remove
// Refresh the peer relationship rest of the nodes in the cluster (iBGP peers). Node add/remove
// events should ensure peer relationship with only currently active nodes. In case
// we miss any events from API server this method which is called periodically
// ensure peer relationship with removed nodes is deleted. Also update Pod subnet ipset.
func (nrc *NetworkRoutingController) syncPeers() {
func (nrc *NetworkRoutingController) syncInternalPeers() {

glog.Infof("Syncing BGP peers for the node.")

Expand Down Expand Up @@ -1379,6 +1381,7 @@ func NewNetworkRoutingController(clientset *kubernetes.Clientset,

nrc := NetworkRoutingController{}
nrc.bgpFullMeshMode = kubeRouterConfig.FullMeshMode
nrc.bgpEnableInternal = kubeRouterConfig.EnableiBGP
nrc.bgpGracefulRestart = kubeRouterConfig.BGPGracefulRestart
nrc.enablePodEgress = kubeRouterConfig.EnablePodEgress
nrc.syncPeriod = kubeRouterConfig.RoutesSyncPeriod
Expand Down Expand Up @@ -1459,7 +1462,9 @@ func NewNetworkRoutingController(clientset *kubernetes.Clientset,
"which its configured: " + err.Error())
}

watchers.NodeWatcher.RegisterHandler(&nrc)
if nrc.bgpEnableInternal {
watchers.NodeWatcher.RegisterHandler(&nrc)
}

return &nrc, nil
}
3 changes: 3 additions & 0 deletions app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type KubeRouterConfig struct {
ClusterAsn uint
FullMeshMode bool
BGPGracefulRestart bool
EnableiBGP bool
GlobalHairpinMode bool
NodePortBindOnAllIp bool
EnableOverlay bool
Expand Down Expand Up @@ -89,6 +90,8 @@ func (s *KubeRouterConfig) AddFlags(fs *pflag.FlagSet) {
"Each node in the cluster will setup BGP peering with rest of the nodes.")
fs.BoolVar(&s.BGPGracefulRestart, "bgp-graceful-restart", false,
"Enables the BGP Graceful Restart capability so that routes are preserved on unexpected restarts")
fs.BoolVar(&s.EnableiBGP, "enable-ibgp", true,
"Enables peering with nodes with the same ASN, if disabled will only peer with external BGP peers")
fs.StringVar(&s.HostnameOverride, "hostname-override", s.HostnameOverride,
"Overrides the NodeName of the node. Set this if kube-router is unable to determine your NodeName automatically.")
fs.BoolVar(&s.GlobalHairpinMode, "hairpin-mode", false,
Expand Down

0 comments on commit 2685367

Please sign in to comment.