In Kubernetes (K8S for short), Flannel, as one of the commonly used network plug-ins, provides Overlay Network support for clusters to help Pods communicate with each other across hosts.Flannel supports a variety of back-end network modes to realize this function, mainly including:
1. VXLAN mode:
- VXLAN is a Layer 2 virtualization technology that creates a virtual Layer 2 network across a Layer 3 network by encapsulating Layer 2 Ethernet frames within IP packets. In Flannel, VXLAN mode uses VXLAN tunnels to transfer packets between nodes and Pods on each node can communicate with each other over this virtual network.
2. host-gw mode:
- Host-gw mode does not use tunnel encapsulation technique but directly forwards the Pod traffic between nodes to the corresponding host gateway for processing through routing table configuration. This approach is more efficient because there is no additional protocol encapsulation overhead, but requires that all nodes must be able to reach each other directly through the Layer 3 network.
3. UDP mode:
- UDP mode, in which Flannel uses UDP encapsulation to transmit packets, is similar to VXLAN and is an implementation of Overlay networking, although VXLAN mode is usually more common and recommended because it provides a richer feature set.
4. AWS VPC mode:
- For Kubernetes clusters running in Amazon Web Services (AWS) environments, Flannel can also be configured to use the AWS VPC CNI plugin to directly utilize AWS network infrastructure such as ENI (Elastic Network Interface) for network connectivity between Pods.
In summary, Flannel may add support for additional backend modes over time and as technology evolves, but at the time of the information above as of this date, the primary modes used were VXLAN, host-gw, and UDP. The selection of the appropriate mode for a particular environment depends on factors such as the actual network architecture, performance requirements, and scalability.