1、概述html
前面咱們部署calico因爲集羣規模不是很大,使用的是calico的bgp模式的node-to-node-mesh全節點互聯,這種模式在小規模集羣裏面還能夠用,3.4.0版本的calico支持到100多個節點。node
可是隨着集羣規模的擴大,bgp的mesh會變得很混亂,由於node-to-node-mesh模式要求全部的node節點都要互聯。因此大規模集羣使用bgp route reflector,集中式的路由信息分發,當Calico BGP客戶端將路由從其FIB通告到Route Reflector時,Route Reflector會將這些路由通告給部署集羣中的其餘節點。api
2、部署app
在官網下載最新的部署文件:https://docs.projectcalico.org/v3.4/getting-started/kubernetes/installation/calicocurl
curl \ https://docs.projectcalico.org/v3.4/getting-started/kubernetes/installation/hosted/calico.yaml \
-O
須要修改幾個地方具體參考:https://www.cnblogs.com/cuishuai/p/9897006.htmlui
calico默認使用的是node-to-node-mesh,咱們須要全局禁用這種模式,須要提早部署calicoctl。url
參考:https://www.cnblogs.com/cuishuai/p/9897006.html、https://docs.projectcalico.org/v3.4/usage/calicoctl/installspa
參考:https://docs.projectcalico.org/v3.4/usage/configuration/bgpcode
一、禁用node-to-node-meshhtm
#cat off-node-mesh.yaml
apiVersion: projectcalico.org/v3 kind: BGPConfiguration metadata: name: default spec: logSeverityScreen: Info nodeToNodeMeshEnabled: false asNumber: 63400
calicoctl apply -f off-node-mesh.yaml
二、配置集羣內路由反射器
# calicoctl get node NAME ku13-1 ku13-2 ku13-3 ku13-4
ku13-4是咱們的kube-gateway,參考https://www.cnblogs.com/cuishuai/p/10310698.html
咱們將這個節點做爲bgp route reflector,建議選2-3個節點做爲route reflector,這裏咱們就用這一個節點,前面已經知道這個節點上只部署了calico-node、kube-proxy,而且禁止調度。
1) 修改節點資源:
將節點設置spec.bgp.routeReflectorClusterID
爲非空集羣ID,例如 224.0.0.1
添加一個標籤,指示該節點是路由反射器
# calicoctl get node ku13-4 --export -o yaml > node.yaml
ku13-4是要選擇的節點名稱,能夠替換成任意的節點,這裏咱們選擇kube-gateway節點。
修改成以下內容:
#cat node.yaml
apiVersion: projectcalico.org/v3 kind: Node metadata: creationTimestamp: null labels: i-am-a-route-reflector: "true" name: ku13-4 spec: bgp: ipv4Address: 10.42.11.1/16 routeReflectorClusterID: 224.0.0.1 orchRefs: - nodeName: ku13-4 orchestrator: k8s
使配置生效:
calicoctl apply -f node.yaml
2)配置BGPPeer資源,告訴其餘Calico節點與路由反射器節點對等:
#cat bgp-calico.yaml
apiVersion: projectcalico.org/v3 kind: BGPPeer metadata: name: peer-to-rrs spec: nodeSelector: !has(i-am-a-route-reflector) peerSelector: has(i-am-a-route-reflector)
calicoctl create -f bgp-calico.yaml
3)若是選擇多個節點爲route reflector,還須要配置BGPPeer資源,告訴路由反射器節點互相對等:
#cat bgp-reflector.yaml
apiVersion: projectcalico.org/v3 kind: BGPPeer metadata: name: rr-mesh spec: nodeSelector: has(i-am-a-route-reflector) peerSelector: has(i-am-a-route-reflector)
calicoctl create -f bgp-reflector.yaml
https://www.cnblogs.com/cuishuai/p/9897006.html