在大规模的节点网络中如果使用BGP网格,将会产生大量的广播风暴。所以在大规模网路中使用BGP Reflect
。
配置Calico工作为BGP Reflect
模式 在每个节点上工作的BIRD既可以作为BGP客户端,还可以作为BGP Reflect
,所以只需要从众多的节点中找出1个或2个将其配置为Reflect即可。
1.在Calico中要使用Reflect需要使用专用的配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 root@k8s-master01:~/yaml/chapter08 apiVersion: projectcalico.org/v3 kind: Node metadata: labels: route-reflector: true name: k8s-master01 spec: bgp: ipv4Address: 172.16.11.71/24 ipv4IPIPTunnelAddr: 192.168.130.0 routeReflectorClusterID: 1.1.1.1 root@k8s-master01:~/yaml/chapter08 Successfully applied 1 'Node' resource(s)
2.改变node节点的工作模型从BGP peer模式为BGP reflect,需要专用配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 root@k8s-master01:~/yaml/chapter08 kind: BGPPeer apiVersion: projectcalico.org/v3 metadata: name: bgppeer-demo spec: nodeSelector: all() peerSelector: route-reflector == "true" root@k8s-master01:~/yaml/chapter08 Successfully applied 1 'BGPPeer' resource(s) root@k8s-master01:~/yaml/chapter08 Calico process is running. IPv4 BGP status +--------------+-------------------+-------+----------+-------------+ | PEER ADDRESS | PEER TYPE | STATE | SINCE | INFO | +--------------+-------------------+-------+----------+-------------+ | 172.16.11.81 | node-to-node mesh | up | 06:08:26 | Established | | 172.16.11.82 | node-to-node mesh | up | 06:08:27 | Established | | 172.16.11.83 | node-to-node mesh | up | 06:08:27 | Established | | 172.16.11.81 | node specific | start | 09:01:55 | Idle | | 172.16.11.82 | node specific | start | 09:01:55 | Idle | | 172.16.11.83 | node specific | start | 09:01:55 | Idle | +--------------+-------------------+-------+----------+-------------+ IPv6 BGP status No IPv6 peers found.
3.关闭node-to-node mesh模式
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 root@k8s-master01:~/yaml/chapter08 apiVersion: projectcalico.org/v3 kind: BGPConfiguration metadata: name: default spec: logSeverityScreen: Info nodeToNodeMeshEnabled: false asNumber: 63400 root@k8s-master01:~/yaml/chapter08 Successfully applied 1 'BGPConfiguration' resource(s) root@k8s-master01:~/yaml/chapter08 Calico process is running. IPv4 BGP status +--------------+---------------+-------+----------+-------------+ | PEER ADDRESS | PEER TYPE | STATE | SINCE | INFO | +--------------+---------------+-------+----------+-------------+ | 172.16.11.81 | node specific | up | 09:16:20 | Established | | 172.16.11.82 | node specific | up | 09:16:20 | Established | | 172.16.11.83 | node specific | up | 09:16:20 | Established | +--------------+---------------+-------+----------+-------------+ IPv6 BGP status No IPv6 peers found.
总结 要将BGP原有的Node-to-Node mesh的网络改成BGP reflect网络需要3步骤:
在集群中找一个节点当reflector
设定其他节点都能与reflector一对一通信
把其他节点的彼此间通信关闭
多Reflector配置 配置多个reflector时只需要把把第一步进行重复,更改其中的节点名、IP地址,但是标签必须保持一致。然后其他的所有节点都能与这两个reflector进行通信了,但是他们各组件中的通信是借助于etcd进行通信的,所以无论把信息发送给哪个reflector他们都会存储到etcd中,由另外的Reflector向全网进行反射。