If your data center uses a Border Gateway Protocol (BGP) network in a hybrid cloud environment, you can use only the BGP Peer mode. In this case, the switches and routers that are used in the data center must support BGP. Calico is a networking solution that supports overlay networks and BGP networks. This topic describes how to use Calico to configure container networks for Kubernetes clusters that are deployed in data centers.
Prerequisites
A Kubernetes cluster is created in your data center. The Calico plug-in is installed in the cluster. For more information, see Install Calico.
Your data center is connected to Cloud Enterprise Network (CEN). For more information, see Enable communication between on-premises and cloud networks.
Background Information
The following figure shows how a data center is connected to Alibaba Cloud.
Procedure
Use calicoctl to create resource objects that are used to configure a Calico network policy based on the following template.
Set the
asNumberandpeerIPparameters based on your data center.kubectl apply -f - << EOF apiVersion: projectcalico.org/v3 kind: BGPConfiguration metadata: name: default spec: logSeverityScreen: Info nodeToNodeMeshEnabled: false asNumber: 64513 EOFkubectl apply -f - << EOF apiVersion: projectcalico.org/v3 kind: BGPPeer metadata: name: my-global-peer spec: peerIP: 192.168.0.1 asNumber: 64513 EOFCheck whether a new route entry is added through one of the following methods:
Use calicoctl:
[root@master ~]# ./calicoctl node status Calico process is running. IPv4 BGP status +--------------+-----------+-------+----------+-------------+ | PEER ADDRESS | PEER TYPE | STATE | SINCE | INFO | +--------------+-----------+-------+----------+-------------+ | 192.168.0.1 | global | up | 03:38:03 | Established | +--------------+-----------+-------+----------+-------------+ IPv6 BGP status No IPv6 peers found.Check the custom route table of the virtual private cloud (VPC) that is attached to the CEN instance.
Log on to the VPC console.
In the left-side navigation pane, click Route Tables.
On the Route Tables page, click the name of the route table to go to the details page.
Click Route Entry List. Then, click Cloud Enterprise Network to verify that a new route entry is added to the route table.