WEBVTT

00:00.930 --> 00:04.780
-We have now set up the nodes
required to set up a Kubernetes cluster.

00:05.180 --> 00:07.600
We have set up a master
node and two worker nodes,

00:07.600 --> 00:09.470
node 01 and node 02.

00:10.010 --> 00:13.400
Let us now proceed to
the kubeadm documentation page

00:13.400 --> 00:15.240
to install a Kubernetes cluster.

00:15.870 --> 00:17.870
We will start with the prerequisites.

00:18.780 --> 00:21.390
We must have a supported operating system

00:21.390 --> 00:26.280
like for example, Ubuntu 16.04
or higher, which we already do.

00:26.280 --> 00:28.720
That's what we did in the previous demo.

00:28.870 --> 00:30.330
We have some hardware requirements

00:30.330 --> 00:36.170
to have at least 2 GB of RAM, two CPUs,
and network connectivity between the VMs

00:36.480 --> 00:39.870
which we have already taken
care of in the previous video.

00:40.220 --> 00:43.480
Another thing is to make
sure that our firewall

00:43.480 --> 00:46.450
and network security
settings are in place,

00:46.600 --> 00:50.060
otherwise, the nodes will
run into connectivity issues.

00:52.360 --> 00:56.140
For this, we must let
iptables see bridged traffic.

00:56.520 --> 01:02.190
We must first make sure the br_netfilter
module is loaded before the step.

01:02.640 --> 01:09.300
We can do that by running the command
lsmod grep br_netfilter.

01:11.800 --> 01:14.960
We see that it's not
loaded as there is no result

01:15.080 --> 01:19.540
so we run the modprobe command
to load the kernel module.

01:27.310 --> 01:29.730
We now execute that on all the nodes.

01:29.730 --> 01:32.580
[pause]

01:43.490 --> 01:44.610
Once that is done,

01:44.610 --> 01:49.400
we run this set of commands to
create the new kernel parameters.

01:49.760 --> 01:51.950
We then do that on all the nodes.

01:51.950 --> 01:54.680
[pause]

02:11.040 --> 02:14.300
The next step is to install
container runtime on the nodes.

02:14.760 --> 02:17.460
We will be using Docker in this example.

02:18.100 --> 02:21.580
For this, we use the documentation
link and click on Docker.

02:22.450 --> 02:26.540
We will use these commands to install
the latest stable version of Docker.

02:27.160 --> 02:28.930
These need root privileges.

02:29.320 --> 02:32.840
I will switch to sudo to
make the next steps easier

02:32.840 --> 02:35.190
by running the sudo -i command.

02:37.290 --> 02:41.200
I will now paste the command that I copied
to set up the software repositories.

02:41.850 --> 02:46.840
We will then proceed to execute
the same on all the three machines.

02:46.840 --> 02:49.960
[pause]

03:09.080 --> 03:14.020
Okay, that's done, the next step is
to install Docker's official GPG keys.

03:14.700 --> 03:17.390
We will do that also on all the machines.

03:17.390 --> 03:20.160
[pause]

03:32.290 --> 03:36.850
The next step is to add
the Docker apt repository.

03:37.910 --> 03:40.530
We will then do the same
on all the systems.

03:40.530 --> 03:43.090
[pause]

03:55.270 --> 03:57.730
The next step is to install
the Docker runtime.

03:57.730 --> 03:58.960
We run the commands

03:58.960 --> 04:02.760
to install the latest stable version
of Docker as of this recording.

04:04.200 --> 04:08.480
If the version of Docker that's shown
here has changed as you're watching this,

04:08.480 --> 04:11.630
then feel free to follow the latest
version of documentation,

04:11.630 --> 04:13.640
to install the latest version of Docker.

04:15.400 --> 04:17.040
Run that on all the nodes.

04:17.490 --> 04:20.740
This may take a few minutes
so wait for that to finish.

04:20.740 --> 04:23.840
[silence]

04:30.120 --> 04:32.840
The next step is to set up
the Docker daemon.

04:33.140 --> 04:36.280
For this we create a daemon.json file

04:36.280 --> 04:38.820
and then create a directory
for the Docker service.

04:38.820 --> 04:41.880
[pause]

05:08.640 --> 05:13.270
We then run the systemctl daemon
reload and restart Docker command

05:13.270 --> 05:15.810
to load and start the Docker service.

05:15.810 --> 05:18.010
[silence]

05:24.190 --> 05:25.870
To verify Docker is installed,

05:25.870 --> 05:31.580
run the systemctl status docker.service
command and verify that it is running.

05:32.140 --> 05:35.810
Confirm that that's the case
on all the three nodes.

05:37.200 --> 05:39.250
We now go back to the documentation page

05:39.250 --> 05:43.380
to proceed with the installation of
Kubernetes components using kubeadm.

05:45.300 --> 05:48.590
The next step is to install
the Kubernetes related packages

05:48.590 --> 05:52.860
such as the kubeadm, kubelet,
and kubectl on all the nodes.

05:53.540 --> 05:56.820
The kubeadm tool is used
to bootstrap the cluster.

05:57.150 --> 05:59.740
The kubelet is the process
that's responsible

05:59.740 --> 06:02.320
to manage pods
and containers on the nodes

06:02.320 --> 06:05.580
and the kubectl utility is the Kubernetes
Command Line Tool.

06:06.160 --> 06:06.760
For this,

06:06.760 --> 06:11.110
run the commands to update repository
and install the required packages.

06:11.110 --> 06:13.720
[silence]

06:19.540 --> 06:22.590
Run these on all the nodes
and wait for it to finish.

06:22.590 --> 06:25.100
[pause]

06:41.990 --> 06:44.840
The next section about
configuring c group driver

06:44.840 --> 06:46.910
is not applicable when using Docker,

06:47.160 --> 06:51.910
as kubeadm will automatically detect
the group driver for the kubelet.

06:53.050 --> 06:54.480
If you're not using Docker,

06:54.480 --> 06:57.840
then we must follow this step
to specify the c group driver.

06:58.610 --> 07:00.000
We can skip this for now.

07:00.960 --> 07:05.010
The next step is to configure the kubeadm
cluster by clicking on this link.

07:06.500 --> 07:10.610
This takes us to the cluster
creation process using kubeadm.

07:12.700 --> 07:15.930
The first phase is to initialize
control-plane node.

07:17.040 --> 07:19.530
The first step in that is only applicable

07:19.530 --> 07:21.980
if we are deploying
a highly available cluster.

07:22.240 --> 07:23.740
In this demo, we are not.

07:23.740 --> 07:27.270
We just have a single master
node so we will skip that for now.

07:27.920 --> 07:31.310
The next step is to choose
a pod network addon.

07:31.880 --> 07:32.760
When we do that,

07:32.760 --> 07:37.060
decide what network IP address range
we are going to use for the pod.

07:37.690 --> 07:40.380
There are multiple network options
available for networking

07:40.380 --> 07:42.310
between pods in a Kubernetes cluster.

07:42.560 --> 07:44.200
If you click on this link,

07:44.360 --> 07:48.310
which takes you down in that page
to the pod networks section,

07:48.310 --> 07:51.040
you will see different options
for configuring a network

07:51.280 --> 07:56.120
such as Calico, Cilium, Contiv,
Kube-router, Weave, et cetera.

07:56.500 --> 07:58.270
In this case, we will make use of Weave

07:58.530 --> 08:00.240
and we can choose a network range

08:00.240 --> 08:02.880
that does not conflict with
the network of the nodes.

08:03.090 --> 08:08.530
Remember that we configured the nodes
to be in the 192.168.56 network,

08:08.880 --> 08:13.070
we will use a network cidr that's
different from that range.

08:13.500 --> 08:19.300
For pods we will use
10.244.0.0/16 network.

08:20.600 --> 08:22.520
The third step can be ignored as well,

08:22.520 --> 08:24.840
since we are using Docker
as our container runtime,

08:24.840 --> 08:28.720
but in case you're using a different one,
you may use this option to specify that.

08:30.160 --> 08:32.740
The fourth step is what we will configure.

08:32.890 --> 08:36.680
We must specify the Kubernetes
API servers IP address

08:36.680 --> 08:39.360
as the API server advertise address.

08:40.090 --> 08:42.390
This is so that the API server

08:42.390 --> 08:47.600
listens on the correct static IP address
we have set on the master node.

08:47.980 --> 08:51.460
Which will make the API server
accessible to the worker nodes

08:51.460 --> 08:53.960
on any other clients on that IP address.

08:55.200 --> 08:57.480
Once we have decided
the values for the options,

08:57.480 --> 08:59.600
we can proceed with
initializing the cluster

08:59.600 --> 09:01.810
using the kubeadm init command.

09:02.530 --> 09:04.370
We will run this on the master node.

09:04.370 --> 09:07.430
Remember this step must only
be run on the master node

09:07.430 --> 09:10.070
because that's where all
the cluster components

09:10.070 --> 09:12.120
have to be installed and initialized.

09:12.780 --> 09:16.520
We copy and paste the kubeadm
init command on the master node,

09:16.520 --> 09:19.020
we will then pass in all
the required parameters

09:19.020 --> 09:24.390
such as the pod network cidr,
which will be 10.244.0.0/16.

09:28.210 --> 09:30.860
The API server advertise address

09:30.860 --> 09:33.880
is going to be the static IP
address of the master node,

09:37.810 --> 09:41.160
which will be 192.168.56.2

09:41.550 --> 09:43.450
which is the IP address of the master.

09:43.880 --> 09:46.940
Now if you're not sure about
the IP address of the master node,

09:47.170 --> 09:48.240
we can double-check that.

09:48.760 --> 09:52.210
I will for now command this command

09:52.210 --> 09:53.830
so that it is not executed

09:53.970 --> 09:57.350
and that I can later access it
after I confirm the IP address.

09:57.970 --> 10:02.190
I will then run the ifconfig command
to confirm the IP address of the node.

10:03.040 --> 10:05.590
I can confirm that it is
the correct IP address.

10:07.730 --> 10:10.280
I will now run the kubeadm init command.

10:10.640 --> 10:15.110
It runs a set of preflight-test to make
sure all prerequisitesare in place.

10:15.720 --> 10:17.110
Let's give it some time to run.

10:19.320 --> 10:21.420
The checks are complete
and everything looks good.

10:22.160 --> 10:24.960
It proceeds with the creation
of security certificates

10:24.960 --> 10:27.300
and installation of
the various components.

10:29.520 --> 10:32.340
We give it some more time
for the installation to finish.

10:32.990 --> 10:34.800
Now, the installation is complete.

10:35.550 --> 10:38.430
We will now perform
the post-installation tasks.

10:39.200 --> 10:40.480
As the output states,

10:40.530 --> 10:44.230
to start the cluster, you need to
run the following as a regular user.

10:44.770 --> 10:46.960
We've been running
things as the root user.

10:46.960 --> 10:52.560
We will run the logout command to
log out and become the regular user.

10:53.040 --> 10:54.540
Once we are a regular user,

10:54.540 --> 10:57.610
we must create a directory
under the user's home directory

10:57.610 --> 10:59.750
and copy the admin.con file.

11:00.600 --> 11:04.240
The admin.con file has the necessary
information credentials

11:04.240 --> 11:08.920
required to access the Kubernetes cluster
using the kubectl command line utility.

11:09.210 --> 11:13.500
It must be placed in the user's home
directory under the .kube directory.

11:14.200 --> 11:17.230
We run this command to
create the .kube directory

11:17.400 --> 11:22.560
and copy the admin.con file into it
and also set the right ownership on it.

11:24.140 --> 11:27.940
The next step is to deploy
a pod network to the cluster.

11:28.440 --> 11:32.580
Earlier, we decided that we will use
Weave as our pod network solution.

11:34.000 --> 11:34.920
We need to do that.

11:36.080 --> 11:38.230
After the pod network solution is set up,

11:38.340 --> 11:42.440
we will have the worker nodes join
the cluster using the command given here.

11:43.370 --> 11:44.750
Keep a node of the command

11:44.750 --> 11:47.630
that will be used to join
the worker node to the cluster.

11:48.550 --> 11:52.240
I'm just going to copy and echo
the command to my screen terminal

11:52.240 --> 11:56.460
so that it is available in the terminal
history and I can retrieve it later,

11:56.680 --> 11:59.790
or you may just copy it
to an external text editor.

12:01.040 --> 12:05.200
Let's run the kubectl get nodes command
to check the status of the cluster now.

12:05.840 --> 12:09.680
We see that the cluster consists
of the Kubemaster node only

12:09.680 --> 12:12.210
and the status is not ready as of now.

12:12.780 --> 12:15.870
The version is 1.18.3.

12:15.980 --> 12:20.350
The reason it's not ready is because we
do not have a pod network solution.

12:21.070 --> 12:26.100
For this, we go back to the documentation
side and go to the pod network section.

12:26.550 --> 12:29.510
Select Weave and copy
the command to install Weave.

12:32.760 --> 12:34.840
Place it on the master
node and execute it.

12:39.120 --> 12:41.790
We see that the port network
solution is been installed

12:41.790 --> 12:44.240
and all the required
components are created.

12:44.800 --> 12:48.930
It creates a service account, roles,
role bindings, daemonsets, et cetera.

12:49.770 --> 12:51.560
We discussed a lot about each of these

12:51.560 --> 12:54.140
in the certified Kubernetes
administrator course.

12:54.140 --> 12:56.090
We have a section just for networking

12:56.090 --> 12:58.800
where we go from
the absolute basics of network

12:59.070 --> 13:02.090
all the way to how a Weave solution works.

13:02.680 --> 13:04.550
Check that out if you have time.

13:05.130 --> 13:07.960
For now, let's proceed with adding
the worker nodes to the cluster.

13:08.670 --> 13:11.040
For this, we will use the command
we saved earlier.

13:11.450 --> 13:14.260
We will copy it and run it
on both the worker nodes.

13:14.260 --> 13:16.690
[pause]

13:28.370 --> 13:31.730
We see that the node has
successfully joined the cluster.

13:32.660 --> 13:35.890
Now, we run the kubectl get nodes
command on the master node

13:35.890 --> 13:37.440
and we will check the status.

13:37.800 --> 13:41.120
It may take a few minutes for the worker
node to be in a ready state.

13:41.350 --> 13:42.500
Let's monitor that.

13:42.500 --> 13:44.960
[silence]

13:46.640 --> 13:48.950
We now see that they are in a ready state.

13:49.140 --> 13:51.520
Our Kubernetes cluster is now ready.

13:52.190 --> 13:54.610
We can now test by creating some objects.

13:55.160 --> 13:58.920
Let's create a pod using
the kubectl, run NGINX command

13:58.920 --> 14:00.920
and specify the NGINX image.

14:00.920 --> 14:02.920
[silence]

14:07.770 --> 14:11.890
You see it's created a pod by running
the kubectl get pods command.

14:13.160 --> 14:16.680
The pods are still being created
so we wait for a few minutes.

14:17.010 --> 14:19.810
We will see that it's
now in a running state.

14:20.560 --> 14:24.220
We will now delete it using the kubectl
deleting pod command.

14:27.120 --> 14:28.400
That's it for this demo.

14:28.400 --> 14:29.680
Thank you for watching.

