Updated April 15, 2023
Introduction to kubernetes flannel
Flannel in Kubernetes is a virtual layer that is used with containers, it is designed basically for containers only. We have an OpenShift container that makes use of a flannel virtual layer. we have default SDN which stands for Software-defined networking we can use this flannel in place of those components. It also helps to route from container to container which we can understand and have a detailed look at by its architecture design. It consists of different nodes, which are called as flannelId and every flannelId is responsible to do a particular task. In the coming section of the tutorial, we will look into its internal working and how to use this for beginners to understand this better.
How to use Flannel networking?
For this, we will be going to make the setup Flannel networking but we will make a few configurations regards to this, which we will be going to see in this section, so let’s get started to see below;
1) first we will understand and set up the Kubernetes cluster this can be done by using the Flannel add-on. This add-on will help our Kubernetes cluster to run properly, we will also be going to need the pod network to add on which will help us to make communication between the pod.
2) This is not the only network add-on provided by Kubernetes, it has the number of networks add on which helps us to create the cluster but in this article, we will use and set up the flannel network first, so let’s take a look.
3) first try to set up the sysctl value for each of our servers which also includes the master mode as well.
a) run the below command to set the sysctl value for the server: sudo tee -a /etc/sysctl.conf
b) to see the changes or apply them permanently we will be going to run the below command. This will apply to the changes we have made in sysctl.confg file.
sudo sysctl -p
c) These changes we will going to do for all the clusters that we have already discussed in the above section of the article.
d) Now we will make use of the flannel.yml file, which helps us to create the different objects for us which will turn help us to run the flannel properly. These step changes we have to make on the master node not on the cluster node this is an important point to add here.
kubectl apply -f
e) To verify the different types of objects are created or not we can run the below command on the command prompt;
kubectl get nodes
f) after running this command we can easily see that all our clusters and the master nodes are running and are in Ready state. This will tell us if our cluster has been set up properly or not it is a validating step.
g) If you want to verify the pods of flannel run the below command, this will tell if the pods are running properly or notkubectl get pods -n Kube-system
Kubernetes flannel model
In this section, we will see the flannel model with the help of a flow chart and diagram. This will helps us to understand the model in a better way so let’s get stated see below;
1) this makes use of host-gw which helps us to move or route from container to container.
2) It consists of several nodes, this node further contains the pods, etc.
3) each host is associated with the flannel id which is responsible for several tasks.
a) it helps us to manage the routes between the several containers that is from container to container.
b) it helps us to mage the unique subnet on each of the hosts
c) it has distributed IP address for each of the containers on the host.
4) We can see the below diagram to understand the flannel model, which helps us to understand the flow of data from a container to a container by making use of flanneId. see below for better clarity;
Kubernetes Traffic Routing
In Kubernetes for Traffic Routing, we make use of Service Topology, this topology helps us to route the traffic, which is based on the node topology of the cluster. By the use of this, we can easily route the traffic to the specific endpoints which are on the same node, or if they are on the same availability zone. By the use of this, we can route traffic between different nodes.
For that we make use of Traffic aware topology, by default traffic will be routed through the nodeId or cluserId of the backend service, but from the Kubernetes 1.7 now it is possible to route traffic to the pods running on the same node.
1) Service Topology: as we already know it helps us to control the traffic, if this feature is enabled on our service then we can route the traffic by the use of topologyKeys. It tries to match the value of the node with the labels, if no value matches with the first labels it goes to the second node and so on.
A few of the options are mentioned below;
This we can specify using the json format like below;
Flannel Networking Space
As we already know that, the Flannel Networking space is consisting of several nodes which contact each other, this node internally contains the pod which acts as the container itself. Let’s take a look at the diagram for this to understand it better;
1) here pos act as the minimum unit.
2) Pod can contain multiple containers
3) Also pods share the same network space, which means they all are connected using the same network interface.
As we have discussed all the points about the flannel in Kubernetes, go through the article it will help your set up and configure flannel for your service in a better way.
We hope that this EDUCBA information on “kubernetes flannel” was beneficial to you. You can view EDUCBA’s recommended articles for more information.