Okay. In this video,
we're going to go through the lab on deploying
a Kubernetes cluster using the kubeadm tool or the kubeadmin tool.
The first question is to install the kubeadm
and the kubelet packages on the controlplane and node01.
There are two nodes.
Currently, we're on the controlplane and then there's also node01
which you can reach if you do just an ssh node01.
We're going to go back.
The first task is to install the kubeadm
and kubelet packages on the controlplane node.
We're going to go to the Kubernetes Documentation page
and just search for kubeadm tool.
Here you have the documentation
for creating a cluster with a kubeadm tool.
We've already learned about this tool,
and that is a simple way for us to create a Kubernetes cluster,
and these are [?] specifications, which our lab environment already has,
and if you are deploying this on your own machine,
then you must make sure that these specifications are met.
The objective of this document
is to install a single control-plane Kubernetes cluster
and to install the Pod network.
That's what we're going to do.
Okay,
the first step is to initialize your control-plane node.
The control-plane node is a machine
where the control-plane components run, which we already know.
The first step is if you have plans to upgrade
this single control-plane to high availability,
you should specify the control-plane-endpoint.
As part of this lab, we're not going to do this,
we're not deploying a highly available cluster.
We're just doing a single control-plane, so that's fine.
Choose a Pod network add-on and verify whether it requires any arguments.
We're going to do this.
I'm going to open this as well.
What we're going to do is,
the Pod network we're going to deploy is flannel.
That's what we're going to go with.
Yes, the rest of these are irrelevant for this lab.
Let's go here.
Okay. These are steps after installing the kubeadm tool, but before this,
we must have installed the kubeadm tool, so let's go back here.
Here we have instructions to install the kubeadm tool,
and this is where we start.
Verify the MAC address and product_uuid.
We know that all of these are met,
so the first task is to verify the MAC address
and product_uuid are unique for every node,
so we can run the ifconfigure, the IP address command.
I'm just going to run the IP address command,
and here we see all the links and all the interfaces.
Here we have the eth0, which is what we're going to use,
which is the [?] network.
Here you see the IP address of the control-plane node,
which is 10.48.6.6.
Here you have MAC address,
and then the other thing that we need to check is
the product_uuid.
This is another thing that we want to make sure is unique.
Run that.
That's the product_uuid.
We're going to go on to node01, and we'll do the same thing.
We'll run the IP address command, and here we have eth0,
the IP address for node01 is 10.48.6.9.
This is 6.6, so they are unique.
This is a MAC address, which ends with 06:06, and this is 06:09,
so that's unique as well.
Now let's look at the product ID.
We're going to copy this.
Run this on node01, and we see that this is different as well.
We're all set with that.
Let's go back to the control-plane node.
The next step is letting iptables see bridged traffic.
We're already set with this, the network adapter,
and the IP addresses are all set, so then we're good with that.
Maybe we can just try to--
We've already done ssh to node01,
but we can just make sure that the nodes are reachable.
Okay.
The next step is to let iptables see bridged traffic.
For this, these are the commands to run.
We're basically setting
the br_netfilter module.
The next step is this.
Checking the required ports.
That's already set.
The next step is to install runtime.
We are using Linux.
This is what we're going to see,
and I think we are going to be using Docker.
Let me check.
Yes, Docker is already installed, and
the Docker status,
the Docker service is running as well,
so that's good.
The next step is to install kubeadm and the kubelet.
If you look here, here we have instructions
on installing kubeadm and Kubelet for different distributions.
Let's see what system we are on.
We're going to do a /etc/-release-, and we see that we are on Ubuntu.
That's Debian-based system.
We are here, and this is what we need to do.
First, we're going to update the apt package index,
and then we're going to download the Google Cloud public signing key.
We're going to add the Kubernetes apt repository,
and then we're going to install the packages.
Now, remember that here it said that we have to use the exact version,
so that's something that we have to keep in mind.
Let's start with the first steps.
We're going to update now the package index
and install the required packages.
Okay.
Now, the next step is to download the Google Cloud public signing key.
That's that.
Then adding the Kubernetes apt repository.
The final step is to update the apt package index,
and then we're going to install these packages,
but just remember that since we're asked to install a specific version,
we have to specify the version in the command.
Right here, specify 1.21.0-00.
Same for this, 1.21.0-00.
Same for this, kubelet, kubeadm, and Kubectl,
and we'll wait for that to be installed.
Okay.
That's done.
Then we have to place a hold on these packages.
That's what the apt-mark hold command does
and what it helps us is in placing a hold on these packages
so that these packages are not accidentally upgraded or removed
when other packages are upgraded.
That's what that's for.
I think that's the first step.
The first step is complete, so let's check our work.
It's not--
We also have to do this on node01, we didn't do that,
so let's go ahead and do that.
We're going to go back and do the same on node01.
We have to start from here.
Okay.
Then we're going to have to check if the container runtime is running.
Let's see status of Docker.
Yes, Docker is running, we're good there.
The next step is to install the packages.
I'm going to start from here,
and we're going to add Google public signing key.
Then we're going to add the Kubernetes apt repository.
Then we're going to update package index.
Finally, we're going to on this, but we're going to have
1.21.0-00,
and finally, we're going to add a hold to the packages.
Okay, so let's check our work.
All right.
Now, the next question is
to identify the version of the kubelet,
so we'll do a kubelet --version.
Now, we know what it is because we just installed it,
but just remember that running the kubelet
version command is used to identify the version.
That's 1.21.0.
Is this one.
How many nodes are part of the Kubernetes cluster currently?
We don't expect any nodes.
That's right, yes.
There's no server type, there's nothing called nodes, so there's zero.
Let's now bootstrap a Kubernetes cluster using kubeadm.
Here we're going to initialize the Control Plane Node (Master Node).
Use the following options.
We're going to do a kubeadm init with these options,
the advertise-address, certificate, and the certificate option,
and then the pod networking address.
That is this part of the documentation page,
so creating a cluster with the kubeadm tool, and we've already--
These are all good.
We're just going to go
into the kubeadm init section.
The idea is to run the kubeadm init on the control-plane
and then run the kubeadm join on the worker nodes.
We're not going to do this because we're going to deploy
a single control-plane cluster.
The pod-network-cidr option is what's given here.
That's 10.244.0.0,
and then these are not relevant at the moment.
We're just going to run the kubeadm init command,
and we'll specify the apiserver address here,
but we don't know what the address is, so let's find that out first.
The IP address of the control-panel node is 10.48.6.6.
We'll use that. That's kubeadm init,
that's option, and the IP is going to be this,
and the apiserver-cert-extra-sans
is going to be controlplane
and the pod networking
cidr is going to be this.
Okay, that should be it.
This should take a minute or so to complete,
so let's just give it some time.
Okay, that operation is complete,
and our Kubernetes controlplane has initialized successfully.
The first step is, to start using your cluster,
you need to run the following as a regular user,
so I'm going to run these commands.
That's basically going to set
the default kube/config to the right files.
Alternatively, if you're the root user, you can export, you can run this.
Now, you should now deploy a pod network to the cluster.
I think that's coming up in the upcoming questions, so we'll skip that.
Let's check.
Okay.
Let's run.
Generate a kubeadm join token.
In the output of the command
that we just ran, the kubeadm init command,
there was the token and the command
that we can use to join a new node to the cluster,
but for some reason,
if you didn't note that down
or accidentally cleared your screen,
or if you ever want to create a new token for a new node,
you could use the kubeadm join token --help command,
and the token command is used to create, delete, or generate new tokens.
We're going to do a create.
This basically just creates the token.
Kubeadm token create, let's not give a token,
and we'll just have the kubeadm tool generate a random token for us.
Then we'll also use the --print-join-command,
which makes it very easy for us to just copy and paste the command.
It's just going to give us the command.
Here it is.
This is the kubeadm join command.
We'll take that, and then we'll go to node01,
and we're just going to run that command here.
You can run this command on any node that you've set
up to be a worker node for the Kubernetes cluster.
Let's check our work.
Okay, that's successful.
Let's go back and let's run the kubectl
get nodes command just to verify the nodes are there.
The nodes are there, node01 is discovered,
but the status is not ready
because we have not installed a network plugin.
That's important.
We're going to install a network plugin, and we'll just go with flannel.
We're going to look up at the documentation pages and find
installing addons.
Here we have Networking and Network Policy add-ons,
and from this, we're going to use flannel.
Here you see deploying flannel manually,
and this is the command that needs to be run,
basically applies the configuration [?] for flannel.
Let's check the status of the pods.
This creates pods in the kube-system namespace.
You see that they are initializing.
We're going to watch that and give it some time for it to run.
Okay, the pod is initializing, and it's now running.
Let's check the status of the nodes now.
The nodes are now in a ready state.
Okay, that's it.
The cluster is set up,
and it's now in a ready state
ready to deploy applications.
From this lab, you have learned how to use
the kubeadm tool to deploy a two-node cluster,
and join the worker node
using the token on the master node.
All right. That's the end of this lab.