c12s-kubespray/roles/network_plugin/calico/rr/files/bird6.cfg.template
2017-04-24 15:19:19 +02:00

85 lines
3 KiB
Text

# Generated by confd
router id {{getenv "IP"}}; # Use IPv4 address since router id is 4 octets, even in MP-BGP
# Watch interface up/down events.
protocol device {
scan time 2; # Scan interfaces every 2 seconds
}
{{if eq "" (getenv "IP6")}}# IPv6 disabled on this node.
{{else}}
# Template for all BGP clients
template bgp bgp_template {
debug off;
description "Connection to BGP peer";
multihop;
import all; # Import all routes, since we don't know what the upstream
# topology is and therefore have to trust the ToR/RR.
export all; # Export all.
source address {{getenv "IP6"}}; # The local address we use for the TCP connection
graceful restart; # See comment in kernel section about graceful restart.
}
{{$our_rr_key := printf "/rr_v6/%s" (getenv "IP6")}}
{{if ls $our_rr_key}}{{$our_rr_data := json (getv $our_rr_key)}}
# ------------- RR-to-RR full mesh -------------
{{if ls "/rr_v6"}}
{{range gets "/rr_v6/*"}}{{$data := json .Value}}{{$rr_ip := $data.ip}}
{{$nums := split $rr_ip ":"}}{{$id := join $nums "_"}}
# For RR {{$rr_ip}}
{{if eq $rr_ip (getenv "IP6") }}# Skipping ourselves
{{else if ne "" $rr_ip}}protocol bgp Mesh_{{$id}} from bgp_template {
local as {{getv "/global/as_num"}};
neighbor {{$rr_ip}} as {{getv "/global/as_num"}};
}{{end}}{{end}}
{{end}}
# ------------- RR as a global peer -------------
{{if ls "/global/peer_v6"}}
{{range gets "/global/peer_v6/*"}}{{$data := json .Value}}
{{if eq $data.ip (getenv "IP6")}}
# This RR is a global peer with *all* calico nodes.
{{range $cnode := lsdir "/host"}}
{{$cnode_as_key := printf "/host/%s/as_num" $cnode}}
{{$cnode_ip_key := printf "/host/%s/ip_addr_v6" $cnode}}{{$cnode_ip := getv $cnode_ip_key}}
{{$nums := split $cnode_ip "."}}{{$id := join $nums "_"}}
# Peering with Calico node {{$cnode}}
protocol bgp Global_{{$id}} from bgp_template {
local as {{$data.as_num}};
neighbor {{$cnode_ip}} as {{if exists $cnode_as_key}}{{getv $cnode_as_key}}{{else}}{{getv "/global/as_num"}}{{end}};
rr client;
{{if $our_rr_data.cluster_id}}rr cluster id {{$our_rr_data.cluster_id}};{{end}}
}
{{end}}
{{end}}
{{end}}
{{end}}
# ------------- RR as a node-specific peer -------------
{{range $cnode := lsdir "/host"}}
{{$node_peers_key := printf "/host/%s/peer_v6" $cnode}}
{{if ls $node_peers_key}}
{{range $peer := gets (printf "%s/*" $node_peers_key)}}{{$data := json $peer.Value}}
{{if eq $data.ip (getenv "IP")}}
{{$cnode_as_key := printf "/host/%s/as_num" $cnode}}
{{$cnode_ip_key := printf "/host/%s/ip_addr_v6" $cnode}}{{$cnode_ip := getv $cnode_ip_key}}
{{$nums := split $cnode_ip "."}}{{$id := join $nums "_"}}
# RR configured as a specific peer for calico node {{$peer.Key}}
protocol bgp Node_{{$id}} from bgp_template {
local as {{$data.as_num}};
neighbor {{$cnode_ip}} as {{if exists $cnode_as_key}}{{getv $cnode_as_key}}{{else}}{{getv "/global/as_num"}}{{end}};
rr client;
{{if $our_rr_data.cluster_id}}rr cluster id {{$our_rr_data.cluster_id}};{{end}}
}
{{end}}
{{end}}
{{end}}
{{end}}
{{end}}
{{end}}