WEBVTT

00:01.050 --> 00:04.140
Hello and welcome to this lecture. In this lecture

00:04.170 --> 00:10.370
we talk about Monitoring a Kubernetes cluster.

00:10.410 --> 00:16.890
So how do you monitor resource consumption on Kubernetes? Or more importantly what would you like

00:16.890 --> 00:18.300
to monitor?

00:18.300 --> 00:23.330
I’d like to know Node level metrics such as the number of nodes in the cluster,

00:23.460 --> 00:31.500
how many of them are healthy as well as performance metrics such as CPU. Memory, network and disk utilization.

00:32.160 --> 00:38.670
As well as POD level metrics such as the number of PODs, and performance metrics of each POD such

00:38.670 --> 00:41.940
as the CPU and Memory consumption on them.

00:41.940 --> 00:48.600
So we need a solution that will monitor these metrics store them and provide analytics around this data

00:49.830 --> 00:56.040
As of this recording, Kubernetes does not come with a full featured built-in monitoring solution.

00:56.040 --> 01:03.510
However, there are a number of open-source solutions available today, such as the Metrics-Server, Prometheus,

01:04.020 --> 01:09.450
Elastic Stack, and proprietary solutions like Datadog and Dynatrace.

01:12.580 --> 01:18.870
Heapster was one of the original projects that enabled monitoring and analysis features for kubernetes

01:18.870 --> 01:25.640
You will see a lot of reference online when you look for reference architectures on monitoring Kubernetes.

01:25.780 --> 01:33.580
However, Heapster is now Deprecated and a slimmed down version was formed known as the Metrics Server.

01:33.580 --> 01:40.310
You can have one metrics server per kubernetes  cluster the metric server retrieves metrics from each

01:40.310 --> 01:46.100
of the kubernetes nodes and pods, aggregates them and stores them in memory.

01:46.100 --> 01:52.340
Note that the metric server is only an in memory monitoring solution and does not store the metrics

01:52.400 --> 01:57.480
on the desk and as a result you cannot see historical performance data.

01:57.650 --> 02:04.760
For that you must rely on one of the advanced monitoring solutions we talked about earlier in this lecture.

02:04.760 --> 02:10.050
So how are the metrics generated for the PODs on these nodes?  Kubernetes

02:10.060 --> 02:17.040
runs an agent on each node known as the kubelet, which is responsible for receiving instructions

02:17.040 --> 02:22.430
from the kubernetes API master server and running PODs on the nodes.

02:22.650 --> 02:30.750
The kubelet also contains a subcomponent known as as cAdvisor or Container Advisor.  cAdvisor is

02:30.750 --> 02:37.140
responsible for retrieving performance metrics from pods, and exposing them through the kubelet API

02:37.200 --> 02:44.480
to make the metrics available for the Metrics Server. If you are using minikube for your local cluster,

02:44.840 --> 02:46.850
run the command minikube

02:47.000 --> 02:54.770
addons enable metrics-server. For all other environments deploy the metrics server by cloning the

02:54.770 --> 03:00.950
metrics-server deployment files from the github repository. And then deploying the required components

03:01.310 --> 03:08.810
using the kubectl create command.  This command deploys a set of pods,  services and roles to enable

03:08.810 --> 03:14.150
metrics server to poll for performance metrics from the nodes in the cluster.

03:14.150 --> 03:22.190
Once deployed, give the metrics-server some time to collect and process data. Once processed, cluster performance

03:22.190 --> 03:27.700
can be viewed by running the command kubectl top node.

03:27.770 --> 03:34.850
This provides the CPU and Memory consumption of each of the nodes. As you can see 8% of the CPU

03:34.850 --> 03:40.480
on my master node is consumed, which is about 166 milli cores.

03:40.820 --> 03:48.730
Use the kubectl top pod command to view performance metrics of pods in kubernetes.

03:48.890 --> 03:50.420
That's it for this lecture.

03:50.420 --> 03:55.740
Head over to the coding exercises section and practice viewing performance metrics on the kubernetes

03:55.740 --> 03:57.120
cluster.

03:57.170 --> 03:57.660
Thank you.

