Hello and welcome to this lecture in this lecture
We will discuss about one solution based on CNI in particular WeaveWorks. The WeaveWorks
WeaveWorks weave CNI plugin. In the previous practice test,
We saw how it is configured.
Now we will see more details about how it works.
We will start where we left off in the POD Networking Concepts section. We had our own custom CNI script
that we built and integrated into kubelet through CNI. In the previous lecture we saw how, instead
of our custom script, we can integrate the weave plugin. Let us now see how the weave solution works,
as it is important to understand at least one solution
well. You should then be able to relate this to other solutions as well.
So the networking solution we set up manually had a routing table which mapped what networks are on
what hosts.
So 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.
Now that works for a small environment and in a simple network. But in 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.
Think of the kubernetes cluster as our company. And the nodes as different office sites. With each site,
We have different departments and within each department we have different offices.
Someone is office-1 wants to send a packet to office-3 and hands it over to the office boy. All he
knows is it needs to go to office 3 and he doesn’t care who or how it is transported. The office
boy takes the package, gets in his car, looks up address of the target office in GPS, uses directions
on the street and finds his way to the destination site. Delivers the package to Payroll department
who in turn forwards the package to office 3. This works just fine for now. We soon expand
regions and countries and this process no longer works it's hard for the office boy to keep track of
so many routes to these large number of offices across different countries and of course he can’t drive
to these offices by himself. That’s where we decide to outsource all mailing and shipping activities
to a company who does it best.
Once the shipping company is engaged.
The first thing that they do is place their agents in each of our company's sites.
These agents are responsible for managing all shipping activities between sites.
They also keep talking to each other and are well connected so they all know about each other's sites.
The departments in them and the offices in them.
And so when a package is sent from say office 10 to office 3 the shipping agent in that site intercepts
the package, and looks at the target office name,
He knows exactly in which site and department that office is in through his little internal network
with his peers on the other sites.
He then places this package into his own new package with the destination address said to the target
sites location and then sends the package through.
Once the package arrives at the destination it is again intercepted by the agent on that site.
He opens the packet retrieves the original packet and delivers it to the right department. Back to a
world, when the 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 or peer stores a topology of 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 it
weave. Then assigns IP address to each network. The Ips shown here are examples only. In the upcoming
practice test.
test you will figure out the exact range of IP addresses weave assigns on each node.
We will talk about IPAM and how IP addresses are handed out to PODs and containers
in the next lecture.
Remember that a single POD may be attached to multiple bridge networks.
For example you could have a pod attached to the weave bridge as well as the docker bridge created by
Docker.
What path a packet takes to reach destination depends on the route configured on the container. Weave
makes sure that PODs get the correct route configured to reach the agent. And the agent then takes care
of other PODs.
now when a packet is sent from one pod to another on another node, weave intercepts the packet and identifies
that it's 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.
So 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, 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.
Most importantly 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.
This works perfectly for the weave peers.
If you deployed your cluster with the kubeadm tool and weave plugin, you can see the weave peers as pods
deployed on each node. For troubleshooting purpose
view the logs using the kubectl logs
Command. Well that's it for this lecture.
I will see you in the next.