Skip to content

Commit

Permalink
Added "--router-id=" parameter. (#563)
Browse files Browse the repository at this point in the history
For ipv6 it is not possible to use the ip address as router-id
and this parameter is required.
  • Loading branch information
Lars Ekman authored and murali-reddy committed Nov 2, 2018
1 parent 2a82035 commit 535fcc5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/user-guide.md
Expand Up @@ -61,6 +61,7 @@ Usage of kube-router:
--peer-router-multihop-ttl uint8 Enable eBGP multihop supports -- sets multihop-ttl. (Relevant only if ttl >= 2)
--peer-router-passwords strings Password for authenticating against the BGP peer defined with "--peer-router-ips".
--peer-router-ports uints The remote port of the external BGP to which all nodes will peer. If not set, default BGP port (179) will be used. (default [])
--router-id string BGP router-id. Must be specified in a ipv6 only cluster.
--routes-sync-period duration The delay between route updates and advertisements (e.g. '5s', '1m', '2h22m'). Must be greater than 0. (default 5m0s)
--run-firewall Enables Network Policy -- sets up iptables to provide ingress firewall for pods. (default true)
--run-router Enables Pod Networking -- Advertises and learns the routes to Pods via iBGP. (default true)
Expand Down
12 changes: 11 additions & 1 deletion pkg/controllers/routing/network_routes_controller.go
Expand Up @@ -60,6 +60,7 @@ type NetworkRoutingController struct {
nodeName string
nodeSubnet net.IPNet
nodeInterface string
routerId string
isIpv6 bool
activeNodes map[string]bool
mu sync.Mutex
Expand Down Expand Up @@ -676,7 +677,7 @@ func (nrc *NetworkRoutingController) startBgpServer() error {
global := &config.Global{
Config: config.GlobalConfig{
As: nodeAsnNumber,
RouterId: nrc.nodeIP.String(),
RouterId: nrc.routerId,
LocalAddressList: localAddressList,
Port: int32(nrc.bgpPort),
},
Expand Down Expand Up @@ -819,6 +820,15 @@ func NewNetworkRoutingController(clientset kubernetes.Interface,
nrc.nodeIP = nodeIP
nrc.isIpv6 = nodeIP.To4() == nil

if kubeRouterConfig.RouterId != "" {
nrc.routerId = kubeRouterConfig.RouterId
} else {
if nrc.isIpv6 {
return nil, errors.New("Router-id must be specified in ipv6 operation")
}
nrc.routerId = nrc.nodeIP.String()
}

// lets start with assumption we hace necessary IAM creds to access EC2 api
nrc.ec2IamAuthorized = true

Expand Down
2 changes: 2 additions & 0 deletions pkg/options/options.go
Expand Up @@ -47,6 +47,7 @@ type KubeRouterConfig struct {
PeerPasswords []string
PeerPorts []uint
PeerRouters []net.IP
RouterId string
RoutesSyncPeriod time.Duration
RunFirewall bool
RunRouter bool
Expand Down Expand Up @@ -121,6 +122,7 @@ func (s *KubeRouterConfig) AddFlags(fs *pflag.FlagSet) {
"Enables the BGP Graceful Restart capability so that routes are preserved on unexpected restarts")
fs.Uint16Var(&s.BGPPort, "bgp-port", DEFAULT_BGP_PORT,
"The port open for incoming BGP connections and to use for connecting with other BGP peers.")
fs.StringVar(&s.RouterId, "router-id", "", "BGP router-id. Must be specified in a ipv6 only cluster.")
fs.BoolVar(&s.EnableCNI, "enable-cni", true,
"Enable CNI plugin. Disable if you want to use kube-router features alongside another CNI plugin.")
fs.BoolVar(&s.EnableiBGP, "enable-ibgp", true,
Expand Down

0 comments on commit 535fcc5

Please sign in to comment.