DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • The Production-Ready Kubernetes Service Checklist
  • Optimizing Prometheus Queries With PromQL
  • Demystifying Kubernetes in 5 Minutes
  • Strengthening Your Kubernetes Cluster With Pod Security Admission

Trending

  • The Modern Data Stack Is Overrated — Here’s What Works
  • What Is Plagiarism? How to Avoid It and Cite Sources
  • How AI Agents Are Transforming Enterprise Automation Architecture
  • Accelerating AI Inference With TensorRT
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Configure Kubernetes Network With Flannel

Configure Kubernetes Network With Flannel

In this article, see how to configure Kubernetes network with Flannel.

By 
Sudip Sengupta user avatar
Sudip Sengupta
DZone Core CORE ·
Oct. 02, 20 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
20.2K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

Network overlays in Kubernetes clusters are used to address containers, pods, services and external client connectivity.  Overlays are software components that decouple the physical infrastructure from networking services. Overlays encapsulate a packet-within-a-packet to achieve connectivity and routing. An overlay is a virtual network serving on the underlying network or underlay. An underlay is a physical infrastructure supporting connectivity.

The Kubernetes Network Model is that every pod gets its own IP address. You do not have to create link pods manually. Container-to-host port mapping is simplified. Pods are treated like Virtual Machines for port allocation, naming, service discovery, load balancing, application configuration, and migration. Pods can communicate with all nodes without Network Address Translation. And Agents (daemons or kubelets) on a node can communicate with all pods on that node. 

Flannel

Flannel is an open-source virtual network project managed by CoreOS network designed for Kubernetes. Each host in a flannel cluster runs an agent called flanneld. It assigns each host a subnet, which acts as the IP address pool for containers running on the host. Containers can then contact other containers directly, using their IP address. Flannel supports multiple backends for encapsulating packets. The recommended choice is Virtual Extensible LAN (VXLAN), which runs a Layer 2 network on top of a Layer 3 infrastructure. Flannel also supports host-gw, which maps direct routes between hosts in a manner similar to Calico.

Setup

We will be setting up our Kubernetes cluster network using the Flannel network add-on. And although the network plug-in is not provided out of the box, it is required for your cluster to run properly. So, for the pods to communicate with each other, a pod network add-on must be installed.

Kubernetes supports several different network add-on solutions. But for the purpose of this article, we will be using flannel. Moving on to installing the flannel network add-on the first thing that we need to do is there's a sysctl value that we need to set up on all our servers, including master node:

Shell
 




x


 
1
echo "net.bridge.bridge-nf-call-iptables=1" | sudo tee -a /etc/sysctl.conf



This will permanently set that value, which will remain set even if we restart the server.  

In order to apply that change which we just added to the sysctl.conf file, we have to run the following command:

Shell
 




xxxxxxxxxx
1


 
1
sudo sysctl -p


-p:Load sysctl settings from the file specified or /etc/sysctl.conf if none is given


And we need to do this on all of our cluster nodes.

Moving forward,  we will install flannel using the yml template that's provided by CoreOS and their repositories on GitHub. This template is also going to create several different objects allowing Flannel to run successfully. And we are going to be doing this on our master node which is an important step. Make sure that you don't accidentally try to install it on one of your cluster nodes. Remember to run it just on the Kubernetes master:

Shell
 




xxxxxxxxxx
1


 
1
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/bc79dd1505b0c8681ece4de4c0d86c5cd2643275/Documentation/kube-flannel.yml


kubectl apply -f: Apply a configuration change to a resource from a file or stdin.


It is just a yml file which describes the objects required to be installed in a cluster to set up Flannel and get it working. This will also create a whole bunch of objects that are specified by that yml file. So, at this point, that's all! Flannel is installed and everything should be up and running.

You can see from the output that there are several objects that are created here and to verify this installation please run the following:

Shell
 




xxxxxxxxxx
1


 
1
kubectl get nodes



And we see that our master server, as well as our cluster nodes, are in the Ready state. Earlier those were not ready as networking was not installed then. This helps us validate that we have set up our cluster network correctly.

All the back end system pods run in the kube-system namespace, and that includes our Flannel pods. Another way to make sure that the actual Flannel pods are up and running at this point, we have to run the following:

Shell
 




xxxxxxxxxx
1


 
1
kubectl get pods -n kube-system



And you will see that we have our kube-flannel-ds-* pods running. So this validates that our cluster network is configured correctly.

At this point, we have set up a working and functional Kubernetes cluster.

Conclusion

Kubernetes supports a variety of different network solutions and plugins which can implement Kubernetes networking in a variety of different environments. As we see, Flannel is a networking solution that perfectly meets the functionality of the Kubernetes networking model, and it offers a simple networking model that sets up an environment which is suitable for most users and use cases when you only need the basics.


This article was originally published on https://appfleet.com/blog/configure-kubernetes-network-with-flannel/ and has been authorized by Appfleet for a republish.

Kubernetes Network cluster pods

Published at DZone with permission of Sudip Sengupta. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • The Production-Ready Kubernetes Service Checklist
  • Optimizing Prometheus Queries With PromQL
  • Demystifying Kubernetes in 5 Minutes
  • Strengthening Your Kubernetes Cluster With Pod Security Admission

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!