|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * networking/metallb/about-metallb.adoc |
| 4 | + |
| 5 | +[id="nw-metallb-bgp_{context}"] |
| 6 | += MetalLB concepts for BGP mode |
| 7 | + |
| 8 | +In BGP mode, each `speaker` pod advertises the load balancer IP address for a service to each BGP peer. |
| 9 | +BGP peers are commonly network routers that are configured to use the BGP protocol. |
| 10 | +When a router receives traffic for the load balancer IP address, the router picks one of the nodes with a `speaker` pod that advertised the IP address. |
| 11 | +The router sends the traffic to that node. |
| 12 | +After traffic enters the node, the service proxy for the CNI network provider distributes the traffic to all the pods for the service. |
| 13 | + |
| 14 | +The directly-connected router on the same layer 2 network segment as the cluster nodes can be configured as a BGP peer. |
| 15 | +If the directly-connected router is not configured as a BGP peer, you need to configure your network so that packets for load balancer IP addresses are routed between the BGP peers and the cluster nodes that run the `speaker` pods. |
| 16 | + |
| 17 | +Each time a router receives new traffic for the load balancer IP address, it creates a new connection to a node. |
| 18 | +Each router manufacturer has an implementation-specific algorithm for choosing which node to initiate the connection with. |
| 19 | +However, the algorithms commonly are designed to distribute traffic across the available nodes for the purpose of balancing the network load. |
| 20 | + |
| 21 | +If a node becomes unavailable, the router initiates a new connection with another node that has a `speaker` pod that advertises the load balancer IP address. |
| 22 | + |
| 23 | +.MetalLB topology diagram for BGP mode |
| 24 | +image::209_OpenShift_BGP_0122.png["Speaker pods on host network 10.0.1.0/24 use BGP to advertise the load balancer IP address, 203.0.113.200, to a router."] |
| 25 | + |
| 26 | +The preceding graphic shows the following concepts related to MetalLB: |
| 27 | + |
| 28 | +* An application is available through a service that has an IPv4 cluster IP on the `172.130.0.0/16` subnet. |
| 29 | +That IP address is accessible from inside the cluster. |
| 30 | +The service also has an external IP address that MetalLB assigned to the service, `203.0.113.200`. |
| 31 | + |
| 32 | +* Nodes 2 and 3 have a pod for the application. |
| 33 | + |
| 34 | +* The `speaker` daemon set runs a pod on each node. |
| 35 | +The MetalLB Operator starts these pods. |
| 36 | +You can configure MetalLB to specify which nodes run the `speaker` pods. |
| 37 | + |
| 38 | +* Each `speaker` pod is a host-networked pod. |
| 39 | +The IP address for the pod is identical to the IP address for the node on the host network. |
| 40 | + |
| 41 | +* Each `speaker` pod starts a BGP session with all BGP peers and advertises the load balancer IP addresses or aggregated routes to the BGP peers. |
| 42 | +The `speaker` pods advertise that they are part of Autonomous System 65010. |
| 43 | +The diagram shows a router, R1, as a BGP peer within the same Autonomous System. |
| 44 | +However, you can configure MetalLB to start BGP sessions with peers that belong to other Autonomous Systems. |
| 45 | + |
| 46 | +* All the nodes with a `speaker` pod that advertises the load balancer IP address can receive traffic for the service. |
| 47 | + |
| 48 | +** If the external traffic policy for the service is set to `cluster`, then all the `speaker` pods advertise the `203.0.113.200` load balancer IP address and all the nodes with a `speaker` pod can receive traffic for the service. |
| 49 | +At least one endpoint for the service must be in the `Ready` condition. The host prefix is advertised to the router peer only if the external traffic policy is set to `cluster`. |
| 50 | + |
| 51 | +** If the external traffic policy for the service is set to `local`, then only the `speaker` pods that are on the same node as an endpoint in the `Ready` condition for the service can advertise the load balancer IP address. Only those nodes can receive traffic for the service. |
| 52 | +In the preceding graphic, nodes 2 and 3 would advertise `203.0.113.200`. |
| 53 | + |
| 54 | +* You can configure MetalLB to control which `speaker` pods start BGP sessions with specific BGP peers by specifying a node selector when you add a BGP peer custom resource. |
| 55 | + |
| 56 | +* Any routers, such as R1, that are configured to use BGP can be set as BGP peers. |
| 57 | + |
| 58 | +* Client traffic is routed to one of the nodes on the host network. |
| 59 | +After traffic enters the node, the service proxy sends the traffic to the application pod on the same node or another node according to the external traffic policy that you set for the service. |
| 60 | + |
| 61 | +* If a node becomes unavailable, the router detects the failure and initiates a new connection with another node. |
| 62 | +You can configure MetalLB to use a Bidirectional Forwarding Detection (BFD) profile for BGP peers. |
| 63 | +BFD provides faster link failure detection so that routers can initiate new connections earlier than without BFD. |
0 commit comments