Revisiting Pod Networking Concepts
Previously, we discussed custom CNI scripts integrated with kubelet. Often, to set up networking for a container, you might have executed:Traditional vs. Weave Networking Setup
In a manually configured networking setup, a routing table maps networks to hosts. When a packet moves from one pod to another, it exits the pod, enters the router, and then is forwarded to the node hosting the destination pod. This approach works well for small networks, but in larger clusters—where hundreds of nodes and multiple pods exist per node—the routing table can become unwieldy. Imagine a Kubernetes cluster as a company with various office sites (nodes). Consider the following analogy:-
Traditional Approach:
An employee in office 1 sends a package to office 3. An office messenger, using only general directions, makes the delivery. This system works in small companies but becomes increasingly complex as the number of sites grows. -
Weave Approach:
The company hires a dedicated shipping service. Each site has an assigned agent who maintains a complete directory of all routes. When a package is sent, the local agent repackages it with the correct destination, ensuring smooth delivery across multiple offices.
This analogy illustrates how Weave simplifies complex network topologies by delegating routing to dedicated agents on each node.
How Weave Works
In a Kubernetes cluster using the Weave CNI plugin, an agent (or service) runs on every node. These agents share information regarding nodes, networks, and pods to maintain an accurate topology of the cluster. Here’s how it functions:-
Bridge Network:
Weave creates a bridge on each node named “Weave” and assigns IP addresses to create an overlay network (the IP range can be confirmed through testing). -
Multi-Bridge Connectivity:
A single pod can be connected to multiple bridge networks (e.g., the Weave bridge and Docker’s default bridge). The packet routing within the container directs traffic to the appropriate network interface. -
Packet Encapsulation:
When a pod sends a packet destined for a pod on another node, the local Weave agent intercepts it, encapsulates it with new source and destination addresses, and forwards it. On the destination node, the corresponding Weave agent decapsulates the packet and routes it correctly.
Deploying Weave on a Kubernetes Cluster
After setting up your base Kubernetes cluster with properly networked nodes and control plane components, deploying Weave is straightforward. You can deploy Weave as a pod in your cluster using a singlekubectl apply command. This command installs all necessary components including the essential Weave peers as a DaemonSet—ensuring one pod runs on every node.
To deploy Weave, execute:
Troubleshooting Weave
To inspect the logs and troubleshoot issues, list the pods in thekube-system namespace:
kubectl logs command to review the logs of specific pods if issues arise.
Ensure that your cluster’s network policies and firewall rules allow communication between Weave agents, or connectivity issues may occur.