WEBVTT

00:00.860 --> 00:03.320
Hello and welcome to this lecture in this lecture

00:03.320 --> 00:11.030
we will discuss about the Kubernetes Service -ClusterIP. A full stack web application typically has

00:11.060 --> 00:15.420
different kinds of pods hosting different parts of an application.

00:15.590 --> 00:22.040
You may have a number of pods running a front end web server another set of pods running a back end

00:22.040 --> 00:29.480
server, a set of PODs running a key-value store like Redis, another set of PODs running a persistent

00:29.480 --> 00:36.990
database like MySQL. The web front end server needs to communicate to the back end servers and

00:36.990 --> 00:42.420
and the backend-workers need to connect to database as well as the redis services etc..

00:42.690 --> 00:51.180
So what is the right way to establish connectivity between these services or tiers of my application.

00:51.390 --> 00:58.440
The pods all have an IP address assigned to them as we can see on the screen but these IP as we

00:58.440 --> 01:00.360
know are not static.

01:00.360 --> 01:05.580
These pods can go down any time and new pods are created all the time.

01:05.580 --> 01:12.060
And so you cannot rely on these IP addresses for internal communication between the application.

01:12.060 --> 01:21.130
Also what if the first front-end POD at 10.244.0.3 need to connect to a backend service?

01:21.330 --> 01:23.240
Which of the three would it go to

01:23.280 --> 01:25.430
and who makes that decision.

01:25.650 --> 01:33.540
A kubernetes service can help us group these PODs together and provide a single interface to access

01:33.540 --> 01:35.730
the PODs in a group.

01:35.850 --> 01:43.320
For example a service created for the backend PODs will help group all the backend PODs together and

01:43.320 --> 01:48.490
provide a single interface for other PODs to access this service.

01:48.750 --> 01:54.140
The requests are forwarded to one of the PODs under the service randomly.

01:54.210 --> 02:00.660
Similarly create additional services for Redis and allow the backend parts to access the redis systems

02:00.660 --> 02:02.250
through the service.

02:02.250 --> 02:10.830
This enables us to easily and effectively deploy a microservices based application on kubernetes cluster.

02:10.830 --> 02:18.810
Each layer can now scale or move as required without impacting communication between the various services.

02:18.900 --> 02:26.280
Each service gets an IP name assigned to it inside the cluster and that is the name that should be used

02:26.610 --> 02:29.680
by other pods to access the service.

02:29.700 --> 02:37.710
This type of service is known as cluster IP to create such a service as always use a definition file

02:38.040 --> 02:43.560
in the service definition file first used to default template which has API version kind.

02:43.560 --> 02:51.380
Metadata and spec the API version is V1 kind is a service and we will give a name to our service.

02:51.420 --> 03:00.240
We will call it backend under specification we have type and ports the type is cluster IP in fact cluster

03:00.240 --> 03:02.370
IP is the default type.

03:02.370 --> 03:10.430
So even if you didn't specify it it will automatically assume the type to be cluster IP under ports.

03:10.440 --> 03:18.370
We have a target port and port the target port is the port where the backend is exposed which in this

03:18.370 --> 03:24.830
case is 80 and the port is where the service is exposed which is 80 as well.

03:25.180 --> 03:33.040
To link the service to a set of pods we use selector we will refer to the pod definition file and

03:33.040 --> 03:38.530
copy the labels from it and remove it under selector and that should be it.

03:38.650 --> 03:45.580
We can now create the service using the kubectl create command and then check its status using the

03:45.580 --> 03:48.630
kubectlget services command.

03:48.640 --> 03:57.080
The service can be accessed by other PODs using the ClusterIP or the service name.

03:57.160 --> 04:00.640
That's it for this lecture and I will see you in the next lecture.

