WEBVTT

00:00.713 --> 00:03.287
Okay. In this video,

00:03.367 --> 00:05.463
we're going to go through the lab
on deploying

00:05.543 --> 00:09.443
a Kubernetes cluster using
the kubeadm tool or the kubeadmin tool.

00:10.133 --> 00:12.033
The first question is to install the kubeadm

00:12.113 --> 00:15.903
and the kubelet packages
on the controlplane and node01.

00:15.983 --> 00:17.483
There are two nodes.

00:17.903 --> 00:21.603
Currently, we're on the controlplane
and then there's also node01

00:21.683 --> 00:24.813
which you can reach
if you do just an ssh node01.

00:24.893 --> 00:28.043
We're going to go back.

00:29.783 --> 00:31.983
The first task is to install the kubeadm

00:32.063 --> 00:35.093
and kubelet packages
on the controlplane node.

00:36.203 --> 00:40.173
We're going to go to the Kubernetes
Documentation page

00:40.253 --> 00:43.563
and just search for kubeadm tool.

00:43.643 --> 00:45.213
Here you have the documentation

00:45.293 --> 00:47.981
for creating a cluster with a kubeadm tool.

00:51.033 --> 00:53.483
We've already learned about this tool,

00:54.083 --> 00:57.603
and that is a simple way
for us to create a Kubernetes cluster,

00:57.683 --> 01:04.053
and these are [?] specifications,
which our lab environment already has,

01:04.133 --> 01:07.713
and if you are deploying
this on your own machine,

01:07.793 --> 01:11.213
then you must make sure
that these specifications are met.

01:12.293 --> 01:13.620
The objective of this document

01:13.700 --> 01:16.520
is to install a single control-plane
Kubernetes cluster

01:16.600 --> 01:18.213
and to install the Pod network.

01:18.293 --> 01:20.168
That's what we're going to do.

01:21.143 --> 01:22.200
Okay,

01:23.813 --> 01:27.113
the first step is to initialize
your control-plane node.

01:27.743 --> 01:29.133
The control-plane node is a machine

01:29.213 --> 01:32.433
where the control-plane components run,
which we already know.

01:32.513 --> 01:35.223
The first step
is if you have plans to upgrade

01:35.303 --> 01:38.723
this single control-plane
to high availability,

01:39.083 --> 01:41.853
you should specify
the control-plane-endpoint.

01:41.933 --> 01:43.503
As part of this lab,
we're not going to do this,

01:43.583 --> 01:45.873
we're not deploying
a highly available cluster.

01:45.953 --> 01:49.703
We're just doing a single control-plane,
so that's fine.

01:49.973 --> 01:54.293
Choose a Pod network add-on and verify
whether it requires any arguments.

01:55.223 --> 01:56.223
We're going to do this.

01:56.303 --> 01:58.313
I'm going to open this as well.

02:02.423 --> 02:03.663
What we're going to do is,

02:03.743 --> 02:06.923
the Pod network
we're going to deploy is flannel.

02:07.373 --> 02:09.561
That's what we're going to go with.

02:12.353 --> 02:15.603
Yes, the rest
of these are irrelevant for this lab.

02:19.033 --> 02:20.083
Let's go here.

02:21.593 --> 02:27.353
Okay. These are steps after installing
the kubeadm tool, but before this,

02:28.013 --> 02:34.143
we must have installed the kubeadm tool,
so let's go back here.

02:34.223 --> 02:37.523
Here we have instructions
to install the kubeadm tool,

02:38.243 --> 02:41.423
and this is where we start.

02:42.383 --> 02:44.883
Verify the MAC address and product_uuid.

02:45.443 --> 02:46.593
We know that all of these are met,

02:46.673 --> 02:48.873
so the first task
is to verify the MAC address

02:48.953 --> 02:51.243
and product_uuid are unique for every node,

02:51.323 --> 02:55.433
so we can run the ifconfigure,
the IP address command.

02:55.583 --> 02:58.763
I'm just going to run
the IP address command,

02:59.123 --> 03:02.243
and here we see all the links
and all the interfaces.

03:02.513 --> 03:05.673
Here we have the eth0,
which is what we're going to use,

03:05.753 --> 03:08.213
which is the [?] network.

03:08.753 --> 03:11.463
Here you see the IP address
of the control-plane node,

03:11.543 --> 03:13.733
which is 10.48.6.6.

03:14.963 --> 03:16.643
Here you have MAC address,

03:17.393 --> 03:21.293
and then the other thing
that we need to check is

03:26.213 --> 03:27.563
the product_uuid.

03:27.743 --> 03:31.163
This is another thing that we want
to make sure is unique.

03:32.303 --> 03:32.793
Run that.

03:32.873 --> 03:34.520
That's the product_uuid.

03:34.600 --> 03:38.463
We're going to go on to node01,
and we'll do the same thing.

03:38.543 --> 03:42.563
We'll run the IP address command,
and here we have eth0,

03:42.653 --> 03:46.673
the IP address for node01 is 10.48.6.9.

03:47.243 --> 03:49.613
This is 6.6, so they are unique.

03:51.083 --> 03:56.373
This is a MAC address,
which ends with 06:06, and this is 06:09,

03:56.453 --> 03:58.133
so that's unique as well.

03:58.943 --> 04:01.006
Now let's look at the product ID.

04:01.313 --> 04:02.133
We're going to copy this.

04:02.213 --> 04:06.783
Run this on node01,
and we see that this is different as well.

04:06.863 --> 04:08.633
We're all set with that.

04:08.873 --> 04:11.453
Let's go back to the control-plane node.

04:14.753 --> 04:18.953
The next step is letting
iptables see bridged traffic.

04:20.100 --> 04:23.133
We're already set with this,
the network adapter,

04:23.213 --> 04:26.933
and the IP addresses are all set,
so then we're good with that.

04:27.113 --> 04:28.653
Maybe we can just try to--

04:28.733 --> 04:32.073
We've already done ssh to node01,

04:32.153 --> 04:35.393
but we can just make sure
that the nodes are reachable.

04:37.013 --> 04:38.013
Okay.

04:40.823 --> 04:44.213
The next step is to let
iptables see bridged traffic.

04:45.353 --> 04:47.853
For this, these are the commands to run.

04:50.723 --> 04:52.403
We're basically setting

04:54.833 --> 04:57.293
the br_netfilter module.

05:00.263 --> 05:01.913
The next step is this.

05:11.213 --> 05:13.343
Checking the required ports.

05:13.853 --> 05:15.278
That's already set.

05:16.073 --> 05:18.273
The next step is to install runtime.

05:18.353 --> 05:19.778
We are using Linux.

05:20.813 --> 05:23.253
This is what we're going to see,

05:23.333 --> 05:26.633
and I think we are going to be using Docker.

05:27.233 --> 05:28.233
Let me check.

05:31.073 --> 05:33.623
Yes, Docker is already installed, and

05:36.443 --> 05:37.623
the Docker status,

05:37.703 --> 05:40.078
the Docker service is running as well,

05:41.453 --> 05:42.578
so that's good.

05:46.163 --> 05:49.223
The next step is to install
kubeadm and the kubelet.

05:50.033 --> 05:51.787
If you look here, here we have instructions

05:51.867 --> 05:56.703
on installing kubeadm and Kubelet
for different distributions.

05:56.783 --> 05:59.823
Let's see what system we are on.

05:59.903 --> 06:06.893
We're going to do a /etc/-release-,
and we see that we are on Ubuntu.

06:07.313 --> 06:09.353
That's Debian-based system.

06:11.123 --> 06:13.873
We are here, and this is what we need to do.

06:14.213 --> 06:17.543
First, we're going to update
the apt package index,

06:17.843 --> 06:20.943
and then we're going to download
the Google Cloud public signing key.

06:21.023 --> 06:23.943
We're going to add
the Kubernetes apt repository,

06:24.023 --> 06:25.983
and then we're going to install
the packages.

06:26.063 --> 06:29.823
Now, remember that here it said
that we have to use the exact version,

06:29.903 --> 06:33.323
so that's something
that we have to keep in mind.

06:35.093 --> 06:37.156
Let's start with the first steps.

06:40.043 --> 06:42.731
We're going to update now the package index

06:46.343 --> 06:49.463
and install the required packages.

06:55.943 --> 06:56.943
Okay.

06:58.523 --> 07:02.903
Now, the next step is to download
the Google Cloud public signing key.

07:05.433 --> 07:06.433
That's that.

07:07.553 --> 07:12.893
Then adding the Kubernetes apt repository.

07:19.043 --> 07:25.103
The final step is to update
the apt package index,

07:28.103 --> 07:31.373
and then we're going to install
these packages,

07:31.613 --> 07:35.813
but just remember that since we're asked
to install a specific version,

07:36.173 --> 07:38.986
we have to specify
the version in the command.

07:42.293 --> 07:47.363
Right here, specify 1.21.0-00.

07:49.283 --> 07:51.083
Same for this, 1.21.0-00.

07:59.273 --> 08:02.023
Same for this, kubelet,
kubeadm, and Kubectl,

08:07.193 --> 08:09.693
and we'll wait for that to be installed.

08:10.373 --> 08:11.373
Okay.

08:11.867 --> 08:12.867
That's done.

08:13.673 --> 08:15.963
Then we have to place
a hold on these packages.

08:16.043 --> 08:18.243
That's what the apt-mark hold command does

08:18.323 --> 08:23.043
and what it helps us is in placing
a hold on these packages

08:23.123 --> 08:27.443
so that these packages
are not accidentally upgraded or removed

08:28.493 --> 08:31.313
when other packages are upgraded.

08:32.933 --> 08:34.613
That's what that's for.

08:37.193 --> 08:38.193
I think that's the first step.

08:38.273 --> 08:41.453
The first step is complete,
so let's check our work.

08:43.333 --> 08:44.333
It's not--

08:44.573 --> 08:47.463
We also have to do this on node01,
we didn't do that,

08:47.543 --> 08:49.418
so let's go ahead and do that.

08:51.083 --> 08:55.253
We're going to go back
and do the same on node01.

08:56.843 --> 08:58.531
We have to start from here.

09:12.053 --> 09:12.953
Okay.

09:13.033 --> 09:19.703
Then we're going to have to check
if the container runtime is running.

09:19.823 --> 09:22.943
Let's see status of Docker.

09:23.153 --> 09:29.093
Yes, Docker is running, we're good there.

09:33.803 --> 09:36.063
The next step is to install the packages.

09:36.143 --> 09:37.956
I'm going to start from here,

09:51.113 --> 09:56.483
and we're going to add
Google public signing key.

10:04.433 --> 10:08.213
Then we're going to add
the Kubernetes apt repository.

10:11.663 --> 10:16.013
Then we're going to update package index.

10:24.263 --> 10:29.243
Finally, we're going to on this,
but we're going to have

10:41.183 --> 10:43.100
1.21.0-00,

10:48.473 --> 10:52.943
and finally,
we're going to add a hold to the packages.

10:58.043 --> 11:00.083
Okay, so let's check our work.

11:03.593 --> 11:04.593
All right.

11:05.573 --> 11:08.193
Now, the next question is

11:11.900 --> 11:14.133
to identify the version of the kubelet,

11:14.213 --> 11:16.343
so we'll do a kubelet --version.

11:16.793 --> 11:18.963
Now, we know
what it is because we just installed it,

11:19.043 --> 11:21.603
but just remember that running the kubelet

11:21.683 --> 11:23.583
version command is used
to identify the version.

11:23.663 --> 11:27.567
That's 1.21.0.

11:28.000 --> 11:29.000
Is this one.

11:32.533 --> 11:35.853
How many nodes are part
of the Kubernetes cluster currently?

11:35.933 --> 11:38.087
We don't expect any nodes.

11:38.167 --> 11:39.420
That's right, yes.

11:39.500 --> 11:44.393
There's no server type, there's nothing
called nodes, so there's zero.

11:47.873 --> 11:51.353
Let's now bootstrap a Kubernetes
cluster using kubeadm.

11:55.523 --> 11:59.523
Here we're going to initialize
the Control Plane Node (Master Node).

11:59.603 --> 12:01.283
Use the following options.

12:02.303 --> 12:06.323
We're going to do a kubeadm
init with these options,

12:06.983 --> 12:13.043
the advertise-address, certificate,
and the certificate option,

12:13.223 --> 12:17.033
and then the pod networking address.

12:20.543 --> 12:25.173
That is this part of the documentation page,

12:25.253 --> 12:31.733
so creating a cluster with
the kubeadm tool, and we've already--

12:34.103 --> 12:35.528
These are all good.

12:35.813 --> 12:36.753
We're just going to go

12:36.833 --> 12:39.203
into the kubeadm init section.

12:40.367 --> 12:42.813
The idea is to run the kubeadm
init on the control-plane

12:42.893 --> 12:46.103
and then run the kubeadm
join on the worker nodes.

12:49.600 --> 12:52.820
We're not going to do this
because we're going to deploy

12:52.900 --> 12:56.093
a single control-plane cluster.

12:57.473 --> 13:00.443
The pod-network-cidr
option is what's given here.

13:00.593 --> 13:02.993
That's 10.244.0.0,

13:06.053 --> 13:12.533
and then these are not relevant
at the moment.

13:16.043 --> 13:20.183
We're just going to run
the kubeadm init command,

13:21.113 --> 13:26.813
and we'll specify
the apiserver address here,

13:28.043 --> 13:32.063
but we don't know what the address is,
so let's find that out first.

13:32.993 --> 13:37.643
The IP address of the control-panel
node is 10.48.6.6.

13:38.386 --> 13:41.753
We'll use that. That's kubeadm init,

13:46.067 --> 13:50.393
that's option,
and the IP is going to be this,

13:53.783 --> 13:55.853
and the apiserver-cert-extra-sans

14:00.113 --> 14:02.093
is going to be controlplane

14:02.749 --> 14:05.433
and the pod networking

14:06.600 --> 14:10.459
cidr is going to be this.

14:13.253 --> 14:14.933
Okay, that should be it.

14:16.553 --> 14:21.483
This should take a minute or so to complete,

14:21.563 --> 14:25.433
so let's just give it some time.

14:53.273 --> 14:55.343
Okay, that operation is complete,

14:55.463 --> 15:00.383
and our Kubernetes controlplane
has initialized successfully.

15:01.073 --> 15:02.973
The first step is,
to start using your cluster,

15:03.053 --> 15:04.833
you need to run
the following as a regular user,

15:04.913 --> 15:07.943
so I'm going to run these commands.

15:08.963 --> 15:10.776
That's basically going to set

15:12.863 --> 15:15.551
the default kube/config to the right files.

15:17.153 --> 15:20.703
Alternatively, if you're the root user,
you can export, you can run this.

15:20.783 --> 15:24.083
Now, you should now deploy
a pod network to the cluster.

15:25.073 --> 15:29.253
I think that's coming up in the upcoming
questions, so we'll skip that.

15:29.333 --> 15:30.563
Let's check.

15:32.663 --> 15:33.120
Okay.

15:33.200 --> 15:34.403
Let's run.

15:35.003 --> 15:37.073
Generate a kubeadm join token.

15:40.446 --> 15:42.200
In the output of the command

15:42.600 --> 15:45.288
that we just ran, the kubeadm init command,

15:45.953 --> 15:48.900
there was the token and the command

15:49.467 --> 15:53.003
that we can use to join
a new node to the cluster,

15:53.303 --> 15:54.513
but for some reason,

15:54.593 --> 15:55.753
if you didn't note that down

15:55.833 --> 15:58.083
or accidentally cleared your screen,

15:58.283 --> 16:02.213
or if you ever want to create
a new token for a new node,

16:02.603 --> 16:07.403
you could use the kubeadm
join token --help command,

16:11.273 --> 16:16.793
and the token command is used to create,
delete, or generate new tokens.

16:17.033 --> 16:18.721
We're going to do a create.

16:25.043 --> 16:26.943
This basically just creates the token.

16:27.023 --> 16:30.213
Kubeadm token create,
let's not give a token,

16:30.293 --> 16:34.313
and we'll just have the kubeadm
tool generate a random token for us.

16:34.433 --> 16:35.973
Then we'll also use
the --print-join-command,

16:36.053 --> 16:40.293
which makes it very easy for us to just
copy and paste the command.

16:40.373 --> 16:42.387
It's just going to give us the command.

16:42.467 --> 16:43.487
Here it is.

16:43.567 --> 16:45.630
This is the kubeadm join command.

16:48.113 --> 16:51.623
We'll take that,
and then we'll go to node01,

16:54.653 --> 16:57.773
and we're just going to run
that command here.

17:01.193 --> 17:04.923
You can run this command
on any node that you've set

17:05.003 --> 17:07.993
up to be a worker node
for the Kubernetes cluster.

17:09.567 --> 17:10.620
Let's check our work.

17:10.700 --> 17:12.380
Okay, that's successful.

17:12.743 --> 17:16.673
Let's go back and let's run the kubectl

17:18.433 --> 17:21.953
get nodes command just
to verify the nodes are there.

17:22.163 --> 17:26.087
The nodes are there, node01 is discovered,

17:26.167 --> 17:27.633
but the status is not ready

17:27.713 --> 17:30.803
because we have not installed
a network plugin.

17:31.267 --> 17:32.542
That's important.

17:32.667 --> 17:36.429
We're going to install a network plugin,
and we'll just go with flannel.

17:36.509 --> 17:43.079
We're going to look
up at the documentation pages and find

17:45.683 --> 17:47.033
installing addons.

17:49.133 --> 17:52.667
Here we have Networking
and Network Policy add-ons,

17:52.967 --> 17:55.592
and from this, we're going to use flannel.

17:58.643 --> 18:00.993
Here you see deploying flannel manually,

18:01.073 --> 18:04.283
and this is the command
that needs to be run,

18:04.643 --> 18:09.503
basically applies
the configuration [?] for flannel.

18:15.593 --> 18:17.781
Let's check the status of the pods.

18:19.253 --> 18:22.128
This creates pods
in the kube-system namespace.

18:22.913 --> 18:24.573
You see that they are initializing.

18:24.653 --> 18:30.053
We're going to watch that and give
it some time for it to run.

18:32.693 --> 18:35.753
Okay, the pod is initializing,
and it's now running.

18:36.067 --> 18:39.800
Let's check the status of the nodes now.

18:40.667 --> 18:43.133
The nodes are now in a ready state.

18:45.300 --> 18:46.687
Okay, that's it.

18:47.067 --> 18:48.053
The cluster is set up,

18:48.133 --> 18:51.920
and it's now in a ready state

18:52.000 --> 18:53.813
ready to deploy applications.

18:54.893 --> 18:57.353
From this lab, you have learned how to use

18:57.433 --> 19:01.673
the kubeadm tool
to deploy a two-node cluster,

19:02.363 --> 19:06.633
and join the worker node

19:06.826 --> 19:11.300
using the token on the master node.

19:12.200 --> 19:14.575
All right. That's the end of this lab.

