Weaveworks (CNI)

Weaveworks makes Kubernetes management easy. 

Weaveworks is CNI plugin. The networking solution we set up manually had a routing table that mapped what networks are on what hosts

K8s Pod Network
NETWORKGATEWAY
10.244.1.0/24192.168.1.11
10.244.2.0/24192.168.1.12
10.244.3.0/24192.168.1.13
Routing Table

From 10.244.1.2 To 10.244.2.2. When a packet is sent from one pod to the other, it goes out to the network to the router and finds its way to the node that hosts that pod. This works for a small environment and in a simple network.

In the larger environments with 100s of nodes in a cluster and 100s of pods on each node. This is not practical. The routing table may not support so many entries and that is where you need to get creative and look for other solutions. So we need a solution. this solution will install an agent on every node and knows every target GATEWAY. So, he places the package into his own new package within the destination Network. Once the package arrives at the destination it is again intercepted by the agent on the node.

Weave CNI plugin

weave CNI plugin is deployed on a cluster, it deploys an agent or service on each node. They communicate with each other to exchange information regarding the nodes and networks and pods within them. Each agent stores the entire setup that way they know the pods and their IPs on the other nodes. Weave creates its own bridge on the nodes and names weave then assigns IP address to each network.

A single pod may be attached to multiple bridge networks. You could have a pod attached to the weave bridge as well as a docker bridge created by Docker. Weave makes sure that pods get the correct route configured to reach the agent. And the agent then takes care of other pods

If a packet is sent from one pod to another pod on another node, weave intercepts the packet and identifies that it is on a separate network. It then encapsulates this packet into a new one with new source and destination and sends it across the network. Once on the other side, the other weave agent retrieves the packet, decapsulates and routes the packet to the right pod.

How do we deploy weave on a Kubernetes cluster?

Weave and weave peers can be deployed as services or daemons on each node in the cluster manually or if Kubernetes is setup already then an easier way to do that is to deploy it as pods in the cluster. Once the base Kubernetes system is ready with nodes and networking configured correctly between the nodes and the basic control plan components are deployed, the weave can be deployed in the cluster with a single kubectl apply command.

This deploys all the necessary components required for weave in the cluster. And the weave peers are deployed as a daemonset. A daemonset ensures that one pod of the given kind is deployed on all nodes in the cluster.

$ kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"
serviceaccount/weave-net created
clusterrole.rbac.authorization.k8s.io/weave-net created
clusterrolebinding.rbac.authorization.k8s.io/weave-net created
role.rbac.authorization.k8s.io/weave-net created
rolebinding.rbac.authorization.k8s.io/weave-net created
daemonset.apps/weave-net created
$ kubectl get daemonset -n kube-system
NAME         DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
kube-proxy   1         1         1       1            1           kubernetes.io/os=linux   2m57s
weave-net    1         1         1       1            1           <none>                   2m31s

https://www.weave.works/docs/net/latest/kubernetes/kube-addon/

If you deployed the cluster with the kubeadm tool and weave plugin, you can see the weave peers as pods deployed on each node.

Leave a Reply

Your email address will not be published.

ANOTE.DEV