-Okay, let us now walk through this lab to go a little bit more
in detail on network inside, especially on weave.
Let's get started.
How many nodes are part of this cluster including the master and worker nodes?
Okay, let me first set an alias,
and then let's do a get nodes. We see that there are two nodes.
This two is the correct answer here.
Now, what is the networking solution used by this cluster?
We know that we could do that by first looking at the process, the kubelet.
We'll do a ps aux
and grep for kubelet.
We see that the network plugin is cni. We know that it's cni.
Now, we're going to look at the cni plugin
and
we look at the configuration section for cni under /etc/cni.
We see that it's weave.
Weave is the networking solution that's used in this lab.
Let's select weave.
How many weave agents/peers are deployed in this cluster?
Let's do that.
Now, from what we know, we know that on every node, there will be an agent.
There are two node so we should have two agents.
We also know that we can see that,
for sure, by looking at
the past this year.
We see that there are two weave net pods and these are the agents.
The answer is two.
Now, on which nodes are the weave peers present?
Let's do -o wide on the same command
to see the nodes that these pods are present.
Let's do that for a better view.
We see that there are two pods and they are on a controlplane and node01.
One worker nodes only.
One on every node. One on every node is the answer here.
Now, identify the name of the bridge network/interface
created by weave on each part.
If you do a ip link,
we see the interfaces are on the node.
We see that we have lots of interfaces and one of that is weave.
That's the interface that's created here.
You can also check on the worker node which is node01.
Let's do an IP link here.
We also see that there's weave here. It's weave. That's the name.
Now, what is the pod IP address range configured by weave?
We can find that out by looking at the logs of the weave pod.
We could just do a get pods -n kube-system.
We are on node01 so let's go back out.
Let's do a pods -n kube-system.
We see that these are the pods. Let's look at the logs of one of those.
We do a logs
in the kube-system namespace
and let's just copy this.
The container name is weave.
If you look at the beginning of this,
we see that there is an IP allocation range,
and that is 10.50.0.0/16.
This is the IP address range that's going to be used by weave to assign
to all the pods in the cluster.
Now, what is the default gateway configured on the pod scheduled on node01?
Try scheduling a pod on node01 and check IP route output.
Let's do this.
Let's first create a pod so let's do a dry run.
For stuff like this, we should be using the BusyBox image.
Let us do a image=busybox.
When you use BusyBox, we want it to stay alive.
We're going to do a sleep 1000. It stand for 1,000 seconds.
We also want to make sure it lands on node01.
Let's do a dry run.
--dry-run=client.
Let's get the output in a YAML format.
Okay. That was a mistake.
That's an example of what you should not be doing.
These options are the options for the kubectl command,
but because they're put after these two dashes,
they went into the sleep command.
Any option for the [?] should be going before these two dashes.
That was the wrong way to do it.
Let me delete that
busybox,
pod busybox.
Okay. I'm just going to do that again.
I'll do a kubectl run busybox--image=busybox.
Then we're going do a dry-run=client.
I'll put that into a YAML format,
but we'll also have the command pass through, which is sleep 1000.
See if that works. Okay. That's worked.
It's automatically put these and now we're going to do is--
I'll put that to busybox.yaml.
Let's edit that file.
We're going to add a node name because we want this to be placed on node01
and we want it to be surely placed on node01
so we could add a node name, node01.
Okay. Then let's do a kubectl create -f busybox.yaml.
Let's see what happened
and let's see where it placed the node.
It's placed the part on node01,
but now, we've got to go into the pod
and run a command to list the routing table.
We're going to do a Qkubectl exec busybox,
then what we're going to do is we going to do a route -n
or you could do an IP route [?] IP route.
Either of these commands will tell us that the default gateway is 10.50.192.0.
All right? That's the default gateway.
Okay. That's the end of this lab.