Networking

Flannel: A Network Fabric for Containers

Flannel is a simple and easy way to configure a layer 3 network fabric designed for Kubernetes.

title : Flannel is a network fabric for containers, designed for Kubernetes. description : Flannel is a simple and easy way to configure a layer 3 network fabric designed for Kubernetes kubenetes networking Networking details Platforms like Kubernetes assume that each container (pod) has a unique, routable IP inside the cluster. The advantage of this model is that it removes the port mapping complexities that come from sharing a single host IP. Flannel is responsible for providing a layer 3 IPv4 network between multiple nodes in a cluster. Flannel does not control how containers are networked to the host, only how the traffic is transported between hosts. However, flannel does provide a CNI plugin for Kubernetes and a guidance on integrating with Docker. Flannel is focused on networking Flannel is a network overlay for Kubernetes. It provides a way for pods to communicate with each other even if they are not on the same host. Flannel is a simple and lightweight network overlay that is easy to install and configure. Flannel works by creating a virtual network on top of the physical network. This virtual network is made up of tunnels that connect the pods. The tunnels are created using the VXLAN protocol. When a pod sends a packet to another pod, the packet is encapsulated in a VXLAN header and sent to the tunnel that connects the two pods. The tunnel then decapsulates the packet and sends it to the destination pod. Flannel is a layer 3 network, which means that it supports routing between pods. This is in contrast to some other network overlays, such as Docker Swarm, which are layer 2 networks. Flannel does not control how containers are networked to the host. This is the responsibility of the host's operating system. Flannel only controls how traffic is transported between hosts. Flannel provides a CNI plugin for Kubernetes. This plugin makes it easy to install and configure Flannel with Kubernetes. Flannel also provides guidance on integrating with Docker. Here are some of the benefits of using Flannel: It is a simple and lightweight network overlay. It is easy to install and configure. It does not require any additional infrastructure. It is a good choice for small and medium-sized Kubernetes clusters. It supports routing between pods. It is compatible with Kubernetes and Docker. Flannel Overlay Network To achieve kubernetes' network requirements, flannel's idea is simple: create another flat network which runs above the host network, this is the so-called overlay network. All containers(Pod) will be assigned one ip address in this overlay network, they communicate with each other by calling each other's ip address directly. minikube start Install Flannel on Minikube Minikube provide option to select CNI Plugins while starting minikube define cni flag add another working node Minikube Node list Minikube create namespace kube-flannel create 2 busybox pod get pods get more details around this pods The subnet of eth0 should match the CNI subnet We should be able to ping between PoDs. PoDs in the host network of a node can communicate with all pods on all nodes without NAT Now starting a ping from this new PoD busybox 3 (in minikube node ) to busybox1 (in minikube-m02 ). This works as expected. This is possible due to VxLAN implementation in flannel. The VxLAN header is 8 bytes long and has the following format: 24-bit VNID (Virtual Network Identifier): This field identifies the VxLAN network that the packet belongs to. 8-bit Flags: This field contains a few flags that control how the packet is processed. 24-bit Reserved: This field is reserved for future use. 20-byte Outer IP Header: This field contains the IP header of the encapsulated packet. The VxLAN header is encapsulated in a UDP packet, which is then sent over the L3 routed infrastructure. The destination UDP port for VxLAN packets is 4789. When a VxLAN packet arrives at a VTEP, the VTEP decapsulates the packet and forwards the encapsulated packet to the destination host. VxLAN is a popular network virtualization technology that is used to create overlay networks over L3 routed infrastructures. VxLAN is a good choice for network virtualization because it is scalable, efficient, and easy to manage. Join CloudNativeFolks Community or Reach out to me on twitter @sangamtwts