Weave Net: A Deep Dive into Kubernetes Network Plug-in

Shingai Zivuku
8 min readOct 30, 2023

Weave Net is a container network solution for Kubernetes that provides seamless inter-container and cross-host communication. It creates a virtual network between all containers in the cluster, enabling them to communicate directly without the need for any manual network configuration.

This makes Weave Net a popular choice for running containerized applications in Kubernetes, as it simplifies the deployment and management of network infrastructure. Weave Net is also highly scalable, making it suitable for even the largest and most demanding Kubernetes clusters. Let’s delve deeper into its workings and benefits.

Photo by Daryl Han on Unsplash

Key Features of Weave Net

Weave Net offers a variety of key features, including:

  1. Virtual Network: Weave Net creates a virtual software-defined network (SDN) that spans all nodes in the Kubernetes cluster. This SDN provides a consistent network experience for containers across the cluster, regardless of their physical location.
  2. Inter-container and Cross-host Communication: Weave Net automatically assigns IP addresses to containers and establishes network connections between them, both within and between nodes. This allows containers to communicate with each other directly, without any manual network configuration.
  3. Multi-cloud and Hybrid Cloud Support: Weave Net can be deployed in multi-cloud and hybrid cloud environments, making it easy to run containerized applications across a variety of infrastructure providers.
  4. Network Policy: Weave Net supports network policy, which allows administrators to define fine-grained access control rules for network traffic. This helps to improve security and isolation for containerized applications.
  5. Simplified Deployment: Weave Net is easy to deploy and manage, and can be integrated with Kubernetes using the DaemonSet object.

Advantages of Weave Net

  1. Ease of use: One of Weave Net’s design goals is to simplify network configuration and management. It provides a simple command line interface and clear documentation, allowing you to easily set up and operate networks. In addition, Weave Net also supports automatic IP address management, eliminating the need for manual IP configuration.
  2. Flat network topology: Weave Net uses a globally flat network model, which means that all containers can communicate directly with each other, regardless of which host they are running on. This eliminates the need for subnetting and routing configuration, making network communication simpler and more efficient.
  3. Dynamic network topology: Weave Net has an adaptive network topology that automatically adjusts network connections based on the starting and stopping of containers. This ensures that network connectivity is always maintained, even when containers are created or destroyed.
  4. Security: Weave Net provides several security features, including data encryption and access control. It uses network tunneling technology to encrypt communication between containers, and it allows you to configure access policies to restrict communication between containers.
  5. Cross-host networking: Weave Net supports container communication across multiple hosts. It uses virtual network devices and virtual routers to connect containers on different hosts, providing a unified network layer so that containers can communicate transparently.

Disadvantages of Weave Net

  1. Performance Overhead: Weave Net introduces some performance overhead due to its use of software-defined networking (SDN) to implement communication between containers. This overhead is typically minimal, but it can be more noticeable for high-bandwidth applications. Weave Net optimizes the forwarding and processing of network packets, but it cannot completely eliminate the overhead associated with SDN.
  2. Single Points of Failure: There are some potential single points of failure in Weave Net’s architecture. For example, if a Weave Net control node fails, it can disrupt network connectivity for all containers in the cluster. To mitigate this risk, it is recommended to deploy multiple Weave Net control nodes in production environments.
  3. Learning Curve: Weave Net is relatively easy to use, but it still requires some understanding of networking concepts and Kubernetes. New users may need some time to learn how to configure and operate Weave Net in their environment.

Weave Net Implementation Principles

Weave Net provides seamless inter-container and cross-host communication. It achieves this by implementing the following key principles:

Virtual Network Device (VND)

Each Weave Net host maintains a VND called the Weave Bridge. This VND provides a centralized point of connection for all containers on the host. When a container is created, it is assigned a unique virtual MAC address and connected to the Weave Bridge.

Virtual Router (VR)

Each Weave Net host also maintains a VR called the Weave Router. The VR is responsible for managing routing and forwarding between containers on the host and between hosts in the cluster. The VR maintains a routing table that maps container IP addresses to the Weave Bridges on which they are located.

Network Tunneling

When a container needs to communicate with another container on a different host, Weave Net uses network tunneling to establish a secure communication channel between the two hosts. The VR on each host encapsulates the container’s network packets in GRE (Generic Routing Encapsulation) packets and sends them over the tunnel to the VR on the other host. The VR on the other host then decapsulates the GRE packets and forwards the container’s network packets to their destination.

Dynamic Network Topology

Weave Net uses a gossip protocol to dynamically maintain network topology information. Each VR exchanges network information with all other VRs in the cluster, including the container’s IP address, routing rules, and status information. This allows each VR to build a complete picture of the network topology and to update its routing table accordingly.

Usage scenarios

Weave Net is suitable for the following scenarios:

  1. Multi-host container communication: Weave Net is suitable for scenarios where communication needs to be established between containers across multiple hosts. It provides a simple way to connect containers on different hosts and provides a globally flat network model so that containers can communicate directly.
  2. Secure isolation and encrypted communication: Weave Net provides network tunneling and encryption capabilities to ensure that communication between containers is secure. This is useful for scenarios where you need to protect sensitive data and isolate different applications.
  3. Dynamic network topology adjustment: Weave Net’s dynamic network topology function makes it suitable for dynamic scheduling and scaling scenarios of containers. When containers are started or stopped, Weave Net can automatically adjust network connections and routing rules to ensure that communication between containers always remains normal.
  4. Simplify network configuration and management: One of Weave Net’s design goals is to simplify network configuration and management. It provides a simple command line interface and easy-to-understand documentation, allowing you to easily set up and operate their network. Weave Net also supports a variety of automation tools, such as Ansible and Terraform, which can be used to further simplify network deployment and management.

Configuration & Installation

The following are the specific steps to use Weave Net, including configuration and installation.

Configure Weave Net:

  1. Make sure you have a cluster running Kubernetes and have administrator rights.
  2. Install Docker on each host running Kubernetes.
  3. Install the Weave Net binaries on each host. It can be installed on Linux with the following command:
sudo curl -L git.io/weave -o /usr/local/bin/weave
sudo chmod +x /usr/local/bin/weave

4. Create a Weave Net configuration file weave.yamland copy the following content into the file:

apiVersion: v1
kind: ConfigMap
metadata:
name: weave-net
namespace: kube-system
data:
weave-ipalloc-range: "10.32.0.0/12"

The weave-ipalloc-range here is the range used to allocate Weave Net IP addresses. Can be adjusted as needed.

5. Use kubectl the command to apply the configuration file to the Kubernetes cluster:

kubectl apply -f weave.yaml

Install Weave Net:

  1. Open a terminal and use SSH to connect to the master node of the Kubernetes cluster.
  2. Run the following command on the master node to start Weave Net:
sudo weave launch

This will start the Weave Net control node on the master node and create a virtual network.

3. Run the following commands on other nodes to add them to the Weave Net network:

sudo weave join <Master node IP>

Replace <Master node IP> with the actual master node IP address.

4. Make sure that all nodes successfully join the Weave Net network. You can check the status of a node using the following command:

sudo weave status

If everything is fine, you should see the status of all nodes as ready.

At this point, Weave Net has been successfully configured and installed. It automatically manages network communication and routing between containers. Containers can continue to be created and managed in the Kubernetes cluster, and they will be able to communicate over Weave Net.

Please note that the above steps provide basic configuration and installation methods for Weave Net. The specific operations may vary based on your cluster environment and needs.

It is recommended to refer to the official documentation of Weave Net for more detailed configuration and installation instructions before use.

How to solve the single point of failure problem of Weave Net?

In order to solve the single point of failure problem of Weave Net, the following measures can be taken:

  1. Deploy multiple control nodes: It is recommended to deploy multiple Weave Net control nodes in a production environment to improve reliability. Multiple control nodes can form a high-availability cluster, and a master node is selected through the election mechanism to handle network control tasks, while other nodes serve as backups. In this way, even if one node fails, other nodes can take over its work to ensure the normal operation of the network.
  2. Load balancing and failover: In situations where multiple control nodes are deployed, a load balancer can be used to distribute network traffic and enable failover. A load balancer can evenly distribute requests to multiple control nodes, thereby improving network availability and fault tolerance. When a control node fails, the load balancer can automatically switch traffic to other available nodes.
  3. Monitoring and alarming: Implement a comprehensive monitoring and alarming system to promptly detect and respond to single points of failure in Weave Net. The monitoring system can monitor the health status and network connection of the control node and trigger an alarm when an abnormality is detected. This way, administrators can take quick action to resolve problems and reduce network outage time.
  4. Regular backup and recovery: Regularly back up the configuration and status information of Weave Net to enable quick recovery in the event of a failure. Backups can include control node configuration files, key data, network topology information, etc. If a control node fails, the backup can be used to restore the network configuration and restore the normal operation of the network.
  5. Highly available infrastructure: In addition to Weave Net’s own high-availability measures, the infrastructure itself should also be ensured to be highly available. For example, use physical servers, network switches, and storage devices with redundancy and failover capabilities to reduce the impact of hardware failures on Weave Net.

Through the above measures, the availability and fault tolerance of Weave Net can be greatly improved and the impact of single point failure on the network can be reduced. However, specific solutions may vary depending on the environment and needs, and it is recommended to evaluate and select the appropriate solution based on the actual situation.

Conclusion

Weave Net is a powerful and easy-to-use Kubernetes network plug-in that provides simple network configuration and management with advantages such as cross-host container communication, dynamic network topology, and security. However, it also has some performance overhead and single-point-of-failure shortcomings that require you to understand and weigh before using it.

--

--

Shingai Zivuku

Passionate about technology and driven by a love for learning and sharing knowledge