4 videos 📅 2022-11-21 09:00:00 Africa/Blantyre
1:04:49
2022-11-21 11:28:21
44:16
2022-11-21 13:36:53
44:08
2022-11-21 14:41:53
10:27
2022-11-21 15:56:25

Visit the Certified Kubernetes Administrator - Exam Preparation course recordings page

United Arab Emirates - Certified Kubernetes Administrator (CKA) - exam preparation

                WEBVTT

00:00:00.000 --> 00:00:04.340
have an unified view of all participant machines if in case if you're facing any

00:00:04.340 --> 00:00:08.040
challenges it will be easy for us to troubleshoot together that's the whole

00:00:08.040 --> 00:00:13.160
idea so that if I'm not seeing any busy hands here I will simply proceed to

00:00:13.160 --> 00:00:17.280
the next set of topic instead of just asking everyone right it's going

00:00:17.280 --> 00:00:21.840
to help us a lot by this way yeah you will see multiple tabs here home

00:00:21.840 --> 00:00:26.980
desktop and training room click on this tab and then click on join

00:00:26.980 --> 00:00:42.760
training room correct okay first of all yes it it is possible provided for

00:00:42.760 --> 00:00:47.620
example my container already has a bash installed in it which means as part of

00:00:47.620 --> 00:00:52.920
the image the base libraries that you have chosen you have a bash if not at

00:00:52.920 --> 00:00:57.600
this you will have some kind of basic shell so you can get into it and yes it

00:00:57.600 --> 00:01:01.980
is possible you can modify any files configuration files but it is not

00:01:01.980 --> 00:01:06.100
recommended for production for production it should happen through

00:01:06.100 --> 00:01:10.260
config map you need to first modify the config map and then restart the

00:01:10.260 --> 00:01:15.540
part so that the restart will pick the latest configurations but for

00:01:15.540 --> 00:01:20.580
some urgent fixed purposes you can do it but by all means in kubernetes

00:01:20.580 --> 00:01:25.980
it's not recommended because it's completely dynamic with respect to part

00:01:25.980 --> 00:01:30.020
anytime kubernetes can kill the part for which you just modified the

00:01:30.020 --> 00:01:33.140
configuration and they may create a recreate it may recreate and

00:01:33.140 --> 00:01:38.360
replacement part so the best practice is modify the config map restart your

00:01:38.360 --> 00:01:43.460
deployment at the part then it will fix the latest configuration but then

00:01:44.060 --> 00:01:47.220
nothing will stop you if you are going to get a shell inside and

00:01:47.340 --> 00:01:52.800
modify it provided you have root permissions and all those stuff or the

00:01:52.800 --> 00:01:57.480
file modification permissions for those file and all the stuff yep welcome

00:01:57.480 --> 00:02:00.340
four more minutes to complete this activity

00:02:22.200 --> 00:02:35.280
cube CTL config get context one main constraint with respect to

00:02:35.280 --> 00:02:40.160
examination is the time so you will really have a limited time to to

00:02:40.160 --> 00:02:44.260
solve all the questions that they pose so we need to be really fast when

00:02:44.260 --> 00:02:50.080
it comes to executing the commands and so on so on so right so keep that in

00:02:50.080 --> 00:02:57.740
mind so for that we need to have these basic commands to be part of our

00:02:57.740 --> 00:03:01.780
muscle memory then only we can easily have the commands where to go how to

00:03:01.780 --> 00:03:06.360
see all those problems will be kind of easy only during examination but

00:03:06.360 --> 00:03:11.180
whether you will be able to do it within the specified time that's what

00:03:11.780 --> 00:03:15.420
most of the student fails during the examination time constraint time

00:03:15.420 --> 00:03:20.380
constraint so during my hands on time also I will put you in and time

00:03:20.380 --> 00:03:33.700
constraint right so that we can do it bit faster last two minutes please to

00:03:33.700 --> 00:03:39.940
complete this activity okay that's and good question that's what we are

00:03:39.940 --> 00:03:46.420
going to write the part specification using an declarative eml file and

00:03:46.420 --> 00:03:49.760
wherein you can you can put specification for more containers

00:03:49.760 --> 00:03:55.320
imperatively it's I mean using CLA it's bit complex we are going to

00:03:55.320 --> 00:04:02.000
achieve it with an eml file yeah we are we are going to discuss that now

00:04:02.000 --> 00:04:06.760
discuss that now right yeah yeah yeah no problem no problem

00:04:16.140 --> 00:04:21.440
all right you can stop here because there's already time that we allocated

00:04:21.440 --> 00:04:27.180
for that hands on so let's continue on the part topic right part is not it

00:04:27.180 --> 00:04:32.260
over so we are yet to discuss many things within the part so what we

00:04:32.260 --> 00:04:36.680
did we created a part using an run command and we learned the life

00:04:36.680 --> 00:04:44.360
cycle commands right so same if I go back to the command where I created the

00:04:44.360 --> 00:04:53.600
part using the run command in general we will submit this is this is

00:04:53.600 --> 00:04:59.020
posting this to the API server right kubernetes API server so the cube CTL

00:04:59.760 --> 00:05:08.500
is generating an eml file and then it's posting it to this rest API for this

00:05:08.500 --> 00:05:12.340
for this command and equivalent eml file is generated so you can actually

00:05:13.060 --> 00:05:18.420
write your own eml file putting together all the specifications because

00:05:18.420 --> 00:05:22.840
here we are specifying image maybe there are some other flags like name

00:05:22.840 --> 00:05:25.720
you can specify there are many configurations that you can specify

00:05:25.720 --> 00:05:31.240
but you are limited to provide some configurations via CLA but if you are

00:05:31.240 --> 00:05:37.240
going to write an eml file you can actually configure many properties and

00:05:38.040 --> 00:05:42.300
then once you are done with your eml file you can apply this

00:05:42.300 --> 00:05:48.760
configuration to the cluster on your own okay so for that you can start

00:05:48.760 --> 00:05:55.280
start writing the eml file from scratch that is one way but you don't

00:05:55.280 --> 00:06:00.560
want to start from scratch and instead you if you have some base you can just

00:06:00.560 --> 00:06:06.640
build on top of it yes you can do that all you need to do is to the same

00:06:06.640 --> 00:06:13.920
command just include dry run flag I want to dry run this and client and

00:06:14.500 --> 00:06:20.720
output me the eml file you cannot put also in JSON file that doesn't going

00:06:20.720 --> 00:06:25.100
to make difference output is going to be the same so what it means is you

00:06:25.100 --> 00:06:31.380
are requesting the kubectl client to generate the eml file for equivalent for

00:06:31.380 --> 00:06:36.940
this commands and then the options that you provided basically kubectl

00:06:36.940 --> 00:06:41.080
won't submit this request to the server this will run in the client

00:06:41.080 --> 00:06:46.180
side and then the eml will be printed for you so you can copy this and

00:06:46.180 --> 00:06:50.660
then put it into your file you can put additional configurations and then

00:06:50.660 --> 00:06:56.840
you can apply it on your own for example I can write this output to an

00:06:56.840 --> 00:07:09.140
file my first pod dot eml okay so that file already has this contents

00:07:09.140 --> 00:07:15.600
right so you can simply open the file and you can do the

00:07:15.600 --> 00:07:19.620
modifications whatever you want so this is the place if you want to add

00:07:19.620 --> 00:07:25.220
more container then continuous is an array I hope you are all familiar with

00:07:25.220 --> 00:07:31.540
the eml formatting right two spaces two spaces two spaces under the label we

00:07:31.540 --> 00:07:35.180
have two spaces and then its specifications so same way if it is an

00:07:35.180 --> 00:07:39.860
array it will start with I fun so this is first con first entry of the

00:07:39.860 --> 00:07:45.620
array you can define one more one more one more one more and each entry

00:07:45.620 --> 00:07:51.620
is going to be a specification for each and individual containers right so once

00:07:51.620 --> 00:07:55.940
you have the eml file ready and if you want you can make some updates and

00:07:56.740 --> 00:08:00.340
after the update you can simply apply to the cluster so in the eml file you

00:08:00.340 --> 00:08:05.180
can see API version is the top and the kind is specified as part because

00:08:05.180 --> 00:08:08.660
you are going to create a pod resource and some metadata information

00:08:09.200 --> 00:08:15.320
about the pod the name the label and then the spec specification and under

00:08:15.320 --> 00:08:19.900
the containers your specification for your own container and then some

00:08:19.900 --> 00:08:29.260
defaults that it included okay so with this file you can apply this by using

00:08:29.260 --> 00:08:38.140
create command and specify the name of the file my first part dot eml that's

00:08:38.140 --> 00:08:44.060
it if I press enter this is going to create the part with that one

00:08:45.420 --> 00:08:48.360
because this is the first time we are creating the resource we are using

00:08:48.360 --> 00:08:52.780
create command if the resource already exists and if you are modifying some

00:08:52.780 --> 00:08:59.500
property then you can use apply command there are some properties that

00:08:59.500 --> 00:09:03.820
you can modify and apply that will take effect but there are many

00:09:03.820 --> 00:09:07.660
properties that if you are modifying you need to delete and recreate that

00:09:10.480 --> 00:09:15.640
okay so apply will also create in this case there is no part with the name my

00:09:15.640 --> 00:09:24.020
pod is running let's say then it will also do the create okay so let me

00:09:24.740 --> 00:09:37.760
delete that part I think I have the part in the same name already no I

00:09:37.760 --> 00:09:47.860
the name of the file and the same part that you created earlier with

00:09:47.860 --> 00:10:01.120
imperatively okay so defining and creating an part from an from an eml

00:10:05.540 --> 00:10:13.760
okay that is number one number two now if you go to the document cka kubernetes

00:10:13.760 --> 00:10:20.420
working files just we are going to demonstrate couple of concept with this

00:10:20.420 --> 00:10:26.060
with the file in this directory let me open a shell from here

00:10:38.700 --> 00:10:39.820
come on

00:10:54.240 --> 00:10:59.860
okay a lot better now so now for this demo sake we are going to use one

00:10:59.860 --> 00:11:06.060
application this eml file this the eml file similar to what we just created

00:11:06.760 --> 00:11:16.520
for our nginx application okay as you can see the kind is part and the name

00:11:16.520 --> 00:11:21.840
of the part is card and this time it's based on one one one another

00:11:21.840 --> 00:11:29.580
image and it has the specifications name as a card and the port inside

00:11:29.580 --> 00:11:35.320
the container is 8080 and the protocol is TCP the name that we are getting

00:11:35.320 --> 00:11:38.080
HTTP that doesn't matter even if you are going to keep this that's going to

00:11:38.080 --> 00:11:43.040
work but a minimal part configuration as like how we created one for our

00:11:43.040 --> 00:11:47.880
engine next right so if we want to apply this we know how to do this

00:11:47.880 --> 00:11:54.680
apply the file and if you want to check whether it is created and

00:11:54.680 --> 00:12:06.080
running to get parts and the part is running and if you want to access it

00:12:06.080 --> 00:12:13.160
you know how to do it kubectl port forward the name of the part any port

00:12:13.160 --> 00:12:24.660
number in the host machine and then the port within the container go to

00:12:24.660 --> 00:12:32.620
okay yes in a simple react web application that we will use for demo

00:12:32.620 --> 00:12:39.200
purposes right fine we deploy this application now on top of this

00:12:39.200 --> 00:12:43.660
specification we are going to add more configurations or more specifications

00:12:43.660 --> 00:12:51.200
okay the first one that we are going to add is related to health check

00:12:51.200 --> 00:13:03.400
health check what it means let's say I have a container and this container is

00:13:03.400 --> 00:13:07.580
running my application process and there are a lot of records that are

00:13:07.580 --> 00:13:11.340
coming in and your application is processing it and it is sending some

00:13:11.340 --> 00:13:19.360
success response back to the callers now here comes one request while

00:13:19.360 --> 00:13:25.580
processing this request something went wrong in your application code and then

00:13:25.580 --> 00:13:33.360
the application process exited process exited because it is the only process

00:13:33.360 --> 00:13:36.820
that is running inside the container or the parent process that is

00:13:36.820 --> 00:13:42.060
exited container has nothing to execute so this will also exit

00:13:42.060 --> 00:13:47.360
container will also move to exit exist process move to exited state

00:13:47.500 --> 00:13:52.400
container most exited state so for scenarios like this platform that is

00:13:52.400 --> 00:13:56.900
let's say kubelet kubelet component or the kubernetes will react to it

00:13:57.420 --> 00:14:05.720
because container status is exited kubernetes will try to restart restart

00:14:05.720 --> 00:14:11.580
the pod or sometime it will try to create a replacement part so basically a

00:14:11.580 --> 00:14:19.760
platform is taking an action when if the container is exited okay but the

00:14:19.760 --> 00:14:25.800
same scenario it was it was working until a request came and this while

00:14:25.800 --> 00:14:29.860
processing this request your application went into some kind of

00:14:30.700 --> 00:14:36.380
stalled mode or it went into some kind of deadlock situation so which

00:14:36.980 --> 00:14:44.840
the process is not exited because the process is not exited and running the

00:14:44.840 --> 00:14:49.920
container status is shown as and running and kubernetes of course won't

00:14:49.920 --> 00:14:54.660
take any action because it's already in running state but all the request

00:14:54.660 --> 00:15:00.060
that goes after this request it's all getting some kind of error

00:15:00.060 --> 00:15:06.240
responses to the user is a surfacing error because this service is no

00:15:06.240 --> 00:15:12.120
longer returning any responses all the requests are getting timed out because

00:15:12.120 --> 00:15:16.700
one of the previous requests put the application into an some kind of

00:15:16.700 --> 00:15:21.340
stalled mode right we really want kubernetes to take an action in this

00:15:21.340 --> 00:15:26.340
scenario but kubernetes doesn't care about this scenario because it

00:15:26.340 --> 00:15:30.000
refers only the container status it is running the reason why it is show

00:15:30.000 --> 00:15:33.680
is running showing running because the process is running the parent

00:15:34.280 --> 00:15:43.360
running state but in reality the application is unhealthy it's not in a

00:15:43.360 --> 00:15:48.820
position to serve requests so we want kubernetes to take an action if a

00:15:48.820 --> 00:15:54.740
scenario like this happens so that's where the concept of health check

00:15:54.740 --> 00:16:01.600
comes into picture so what we are going to do instead of relying only

00:16:01.600 --> 00:16:08.240
on the container status we are going to take the health check close to

00:16:08.900 --> 00:16:15.040
business code which means if this is your application that is exposing many

00:16:15.040 --> 00:16:19.780
business endpoints let's say product endpoint search endpoint there are many

00:16:19.780 --> 00:16:23.580
business endpoints that this application exposes correct in addition

00:16:23.580 --> 00:16:28.220
to that you are going to write your developer will write a code to expose

00:16:28.220 --> 00:16:32.700
a endpoint called health and calling this endpoint will simply return and

00:16:32.700 --> 00:16:36.980
some sort of success code that's it nothing other than that if if it if

00:16:36.980 --> 00:16:41.900
the request made to here then the response will be sent as an 200 okay

00:16:42.920 --> 00:16:51.340
as simple as that so what Lewis will do is now while submitting the pod

00:16:51.340 --> 00:16:57.220
yaml file Lewis will include a section called liveness probe wherein

00:16:57.220 --> 00:17:02.420
he will specify this information here kubernetes this is the endpoint call

00:17:02.420 --> 00:17:07.440
this endpoint every 30 seconds and expect a successful response if you are

00:17:07.440 --> 00:17:13.380
getting an failure response for three consequent times that is a failure

00:17:13.380 --> 00:17:21.660
threshold then consider that this application is unhealthy and consider

00:17:21.660 --> 00:17:26.200
that the liveness probe is failed which means if a scenario like this

00:17:26.200 --> 00:17:32.580
happens kubernetes already calling your health endpoint every 30 seconds if

00:17:32.580 --> 00:17:38.060
a scenario like this happens then for the next 30 30 seconds kubernetes will

00:17:38.060 --> 00:17:45.560
get an error response so threshold will meet so that time kubernetes will

00:17:45.560 --> 00:17:55.800
understand that okay this particular container is become unhealthy so it

00:17:55.800 --> 00:18:02.740
liveness probe fails the action that kubernetes takes is restarting the pod

00:18:04.120 --> 00:18:07.940
assuming restart is going to be the fresh start of the application

00:18:07.940 --> 00:18:11.660
everything should be work fine should be working fine after the restart

00:18:11.660 --> 00:18:16.360
okay so this is the exact scenario where we want to address with the

00:18:16.360 --> 00:18:21.080
health check and we are going to configure it as part of your pod

00:18:21.080 --> 00:18:26.020
specification with the liveness probe and then you will specify all these

00:18:26.020 --> 00:18:32.540
inputs once you specify it kubernetes is going to perform that probe okay so

00:18:32.540 --> 00:18:41.720
if I open the file where we have the liveness probe configured okay I

00:18:41.720 --> 00:19:03.340
think it will be better if I increase this font size font size okay so the

00:19:03.340 --> 00:19:07.760
only new addition is this section compared to the previous yaml file the

00:19:07.760 --> 00:19:13.520
new addition is this part live does probe it's for an HTTP endpoint healthy

00:19:14.500 --> 00:19:19.340
and periods against is 10 which means every 10 seconds kubernetes is going to

00:19:19.340 --> 00:19:24.800
call this endpoint and it will expect an success response and the failure

00:19:24.800 --> 00:19:29.000
threshold is 3 which means for the consequent three atoms if kubernetes

00:19:29.000 --> 00:19:33.220
receives an failure response from this endpoint then that's the time

00:19:33.220 --> 00:19:39.360
it's going to declare or assume that this part is unhealthy okay we have

00:19:39.360 --> 00:19:43.260
some timeouts against configurations also which means if the call to the

00:19:43.260 --> 00:19:47.980
endpoint timeouts it takes more than one second that is also kubernetes and

00:19:47.980 --> 00:19:53.220
failure initial delays again means what's the container spins up it's

00:19:53.220 --> 00:19:56.720
going to wait for some five seconds before it starts with that health

00:19:56.720 --> 00:20:00.180
check after five seconds every ten seconds it's going to call the

00:20:00.340 --> 00:20:07.480
endpoint right so those configurations right so now you can see this in

00:20:07.480 --> 00:20:11.260
action also let's say I'm going to delete the part that I created

00:20:11.260 --> 00:20:17.000
earlier because the part that I'm going to create now it's with the

00:20:17.000 --> 00:20:26.920
same name one two card board health cube CTL get parts you can see this

00:20:27.480 --> 00:20:36.520
so now I'm going to do the port forward to access the application let me

00:20:36.520 --> 00:20:45.060
refresh this okay we're already here just to demonstrate we are going to

00:20:45.060 --> 00:20:51.020
simulate the scenario if liveness profiles how kubernetes is going to

00:20:51.020 --> 00:20:55.440
act on that scenario right so let's say kubernetes is already calling this

00:20:55.440 --> 00:21:00.080
application in this healthy endpoint every ten seconds right every ten

00:21:00.080 --> 00:21:06.160
second if it calls this application is printing it in on a table okay you can

00:21:06.160 --> 00:21:10.640
see already it's called and this application cell sent 200 response back

00:21:10.640 --> 00:21:15.960
to the kubernetes right now we are going to intentionally send and

00:21:15.960 --> 00:21:21.940
failure response to kubernetes fail for next three calls because three is

00:21:21.940 --> 00:21:29.940
threshold that we set so if I click on three then we are going to send five

00:21:29.940 --> 00:21:40.660
hundred and for the next call again an error code or a failure code the

00:21:40.660 --> 00:21:44.880
third time it's going to send the threshold will hit and it's going to

00:21:44.880 --> 00:21:51.420
be restarted okay as you can see already the part is restarted it's

00:21:51.420 --> 00:21:58.300
waiting for the initial delay second of five and after that you will see again

00:21:59.040 --> 00:22:03.060
the call happen from kubernetes it's going to continue for every ten

00:22:03.060 --> 00:22:09.140
seconds so in this case if we simulated this behavior where the call

00:22:09.140 --> 00:22:13.640
to the health endpoint failed let's say if this happened if all the

00:22:13.640 --> 00:22:19.560
business endpoints are not accessible then the kubernetes will also be won't

00:22:19.560 --> 00:22:23.760
be able to access the health endpoint also so which means we are taking that

00:22:23.760 --> 00:22:27.540
liveness check near to your application code instead of relying

00:22:27.540 --> 00:22:31.940
only on the container status or the process status we are taking it near to

00:22:31.940 --> 00:22:37.240
the app code so that's the whole logic right so if I go back here you

00:22:37.240 --> 00:22:42.320
can even see those informations in the describe command if I do keeps it

00:22:42.320 --> 00:22:48.500
in get parts you can see the part is already restarted one time because it

00:22:48.500 --> 00:22:54.400
liveness probe if you want to see those information you can look at the

00:22:54.400 --> 00:22:55.920
event section

00:23:02.280 --> 00:23:13.080
I think this is the card part right or the my part okay so here you can see

00:23:13.080 --> 00:23:21.300
liveness probe failed with the status code 500 warning unhealthy and then the

00:23:21.300 --> 00:23:23.400
part is restarted

00:23:25.080 --> 00:23:30.040
okay so liveness profile sorry started so the learning from here is what is

00:23:30.040 --> 00:23:35.460
liveness probe and why we need liveness probe this concept explains

00:23:35.460 --> 00:23:41.600
that how to configure it you already seen an aml file if the liveness

00:23:41.600 --> 00:23:49.400
probe fails the action is restarted that's it no complex access just a plain

00:23:49.400 --> 00:23:57.780
restart of the container okay so this liveness probe as you can see here

00:23:57.780 --> 00:24:06.220
from our application we exposed an API slash health endpoint isn't it what if

00:24:06.220 --> 00:24:12.800
your application is an is an is not an API it's some kind of worker process

00:24:12.800 --> 00:24:19.240
that doesn't exposes any API for those purposes we have different options

00:24:19.240 --> 00:24:25.880
under the liveness probe we have HTTP probe that is the one that we just

00:24:25.880 --> 00:24:32.700
seen we will expose an endpoint we also have TCP probe and we also have

00:24:33.300 --> 00:24:38.320
TCP means you are going to probe to and specific port number as long as the

00:24:38.320 --> 00:24:41.640
port is reachable it will be healthy healthy healthy port is not reachable

00:24:41.640 --> 00:24:45.760
then it is an it will hit the unhealthy scenario exact probe means

00:24:45.760 --> 00:24:52.080
you want to execute some command and that command execution should return

00:24:52.080 --> 00:24:55.680
a success or failure code let's say 0 is a success code minus 1 is a

00:24:55.680 --> 00:25:01.060
failure code after execution of the command every 10 seconds as long as you

00:25:01.060 --> 00:25:06.520
the success code then healthy if it is a failure code then unhealthy right

00:25:06.520 --> 00:25:12.260
so you will go for using this kind of probes where exposing an HTTP rest

00:25:12.260 --> 00:25:20.740
API endpoint is not possible okay so you can see here this is using an

00:25:20.740 --> 00:25:26.180
exact probe basically what this is going to do every five second it's

00:25:26.320 --> 00:25:34.940
going to open this file temp healthy okay so as part of this file this is

00:25:34.940 --> 00:25:41.860
creating that file and then slips for 30 seconds and then remove that file

00:25:41.860 --> 00:25:49.400
sleep for five minutes right if you try this you can see also if it is not

00:25:49.400 --> 00:25:54.760
able to find the file then it's going to be the failure scenario cat temp

00:25:54.760 --> 00:26:00.000
health returns and failure code then the pod will be restarted as long as if

00:26:00.000 --> 00:26:04.340
it is able to find the file then the thing will happen which means

00:26:04.340 --> 00:26:08.180
application is healthy so a simple command so this is purely depends your

00:26:08.180 --> 00:26:14.400
application team should know when we should tell that application is

00:26:14.400 --> 00:26:17.400
unhealthy when we should tell that it is healthy based on that they are

00:26:17.400 --> 00:26:22.400
going to write some exact commands here okay that is the exact probe this

00:26:22.400 --> 00:26:26.900
is something that we just seen that is HTTP probe and the last one is TCP probe

00:26:26.900 --> 00:26:33.720
will just specify the port number okay so which means the cubelet will

00:26:33.720 --> 00:26:39.360
attempt to open a socket to your container on the specified part if if

00:26:39.360 --> 00:26:43.240
it can establish a connection then they can consider containers healthy if

00:26:43.240 --> 00:26:50.120
not consider the container is unhealthy okay three types based on the

00:26:50.400 --> 00:26:58.440
application you can configure HTTP probe exact probe or TCP probe okay so this

00:26:58.440 --> 00:27:03.540
is for liveness probe and if the linus probe phase the action is restarting

00:27:03.540 --> 00:27:08.380
the container so similar to liveness probe we have one more called

00:27:08.380 --> 00:27:20.380
readiness this serves a different purpose what is the purpose let's say

00:27:20.380 --> 00:27:25.760
deploying nginx with five replicas five replicas which means five parts will be

00:27:25.760 --> 00:27:31.920
running and here you have one another service that wants to call nginx

00:27:31.920 --> 00:27:36.760
application your application my nginx application so which means you have

00:27:36.760 --> 00:27:41.380
five instances the request needs to be load balanced to one of these five

00:27:41.380 --> 00:27:45.340
so that one part will process it and send the response back to the

00:27:46.400 --> 00:27:51.800
isn't it so for that we are going to create services resource in kubernetes

00:27:51.800 --> 00:27:56.320
that we will discuss in a moment and this is the one that's going to load

00:27:56.320 --> 00:28:02.680
balance to one of these five so in the readiness probe you are going to

00:28:02.680 --> 00:28:06.440
specify the same config similar configuration as how we will specify

00:28:06.440 --> 00:28:11.960
by linus probe maybe we will expose an endpoint called ready and you will

00:28:11.960 --> 00:28:16.360
specify every 10 seconds that should be executed so based on that let's say

00:28:16.360 --> 00:28:21.380
this container passes the readiness probe then this will be set to ready

00:28:21.380 --> 00:28:25.740
ready state in this process ready state ready state ready state let's say

00:28:25.740 --> 00:28:29.820
if this fails readiness probe it will be set to not ready state so by

00:28:29.820 --> 00:28:35.520
the time when a request comes in this service component will consider only

00:28:35.520 --> 00:28:39.920
the replicas that are in ready state that is one two three four and then

00:28:39.920 --> 00:28:46.720
it will load balance to only these four this will simply be excluded because it

00:28:46.720 --> 00:28:51.040
failed the readiness probe because it failed it is in not ready state so it

00:28:51.040 --> 00:28:55.980
won't be considered for the load balancing maybe after a moment it will

00:28:55.980 --> 00:29:02.140
turn to the next next calls it it may succeed it will success succeed the

00:29:02.140 --> 00:29:06.680
readiness probe so that time another request comes in this time this will

00:29:06.680 --> 00:29:12.300
also be considered because it's already transitioned to ready state okay so you

00:29:12.300 --> 00:29:16.760
can have some kind of logic here to determine when your application is

00:29:16.760 --> 00:29:20.440
ready maybe it's still processing the previous request or you don't have

00:29:20.440 --> 00:29:25.460
enough sufficient thread pool to process the request so you may want

00:29:25.460 --> 00:29:29.160
to fail the readiness probe so that you won't get any new request process

00:29:29.160 --> 00:29:34.520
the one that that are already in in it and then once you complete it

00:29:34.520 --> 00:29:38.260
then maybe the readiness probe will succeed and then it will get more

00:29:38.260 --> 00:29:44.040
requests so when a liveness probe fails that is for a different case and a

00:29:44.040 --> 00:29:48.680
part will be restarted if a readiness probe fails it just that that part

00:29:48.680 --> 00:29:53.560
won't be considered for load balancing that's it once it transition to ready

00:29:53.560 --> 00:30:01.020
it will be considered okay so that's what you can see under the readiness

00:30:01.020 --> 00:30:07.040
probe I can show it yeah this one the same for the readiness also you can

00:30:07.040 --> 00:30:13.320
specify the exact HTTP probe here it is an exact proof configured similar to

00:30:13.320 --> 00:30:16.920
the liveness probe okay the only difference is instead of liveness you

00:30:16.920 --> 00:30:24.120
are using the readiness so in our example if you go to the maybe the

00:30:25.120 --> 00:30:32.280
you can see the readiness probe here same configuration is just that we are

00:30:32.280 --> 00:30:36.540
calling another endpoint this may have a logic to tell whether their

00:30:36.540 --> 00:30:40.640
application is in a position to accept the request new request or is

00:30:40.640 --> 00:30:45.400
it still busy with processing the existing request good thing is for the

00:30:45.400 --> 00:30:54.100
both liveness and readiness probe already the framework there are

00:30:54.100 --> 00:30:58.400
some libraries that will take care of exposing these endpoints that will

00:30:58.400 --> 00:31:03.120
determine or that will take care of exposing the endpoints with the

00:31:03.120 --> 00:31:07.860
logics to say whether ready or not ready or your developer can take more

00:31:07.860 --> 00:31:11.620
control and they can write their own logic by implementing this endpoint

00:31:12.860 --> 00:31:18.060
okay but by all means now we are clear with this two probes and the purpose

00:31:18.060 --> 00:31:24.740
of it and what will happen if these profiles any questions so far on this

00:31:24.740 --> 00:31:31.800
any question or is it clear okay good so before trying the hands-on for

00:31:31.800 --> 00:31:37.960
that part so in the in the in the simple part specification now we learned

00:31:37.960 --> 00:31:42.760
how to add the two probes that is readiness and liveness probe now for

00:31:42.760 --> 00:31:46.080
the same part specification we are going to add few more configurations

00:31:46.080 --> 00:31:58.380
which are very very important right one is let's say I have Lewis and let's say

00:31:58.380 --> 00:32:04.600
he is a beginner or he is a trainee he wrote on application and he deployed

00:32:04.600 --> 00:32:08.900
the application into the kubernetes cluster have three nodes n1 n2 and

00:32:08.900 --> 00:32:14.560
n3 and his application is running somewhere here in the node 1 and as

00:32:16.000 --> 00:32:23.640
administrator hemos is already watching this application and he founds out that

00:32:23.640 --> 00:32:29.800
this application has some a problem which means before an hour it was

00:32:29.800 --> 00:32:37.360
using 0.5 CPU and 256 MB of memory now this application is using 1 CPU and

00:32:37.360 --> 00:32:43.040
512 MB of memory and over the period it seems it's it started to use more

00:32:43.040 --> 00:32:48.420
resources even though this application is sitting idle or it's receiving or

00:32:48.420 --> 00:32:54.980
processing only few requests but then it keeps consuming more resources but

00:32:54.980 --> 00:32:59.060
then it never releases the resources back to the pool once it's done with

00:32:59.060 --> 00:33:04.000
the processing which means this application has some serious memory

00:33:04.000 --> 00:33:10.440
leak issues and it's not releasing the resources so which means over the

00:33:10.440 --> 00:33:16.240
period this guy may eat all the resources leaving all other containers

00:33:16.240 --> 00:33:23.940
or parts to stow for the resources this was starving right so clearly as

00:33:23.940 --> 00:33:29.520
administrator I don't want this scenario to happen if something seems

00:33:29.520 --> 00:33:32.740
to happen like this then I want kubernetes to take some action so for

00:33:32.740 --> 00:33:36.940
that you need to educate the kubernetes with some informations while

00:33:36.940 --> 00:33:41.680
submitting the part specification you need to provide some information to

00:33:41.680 --> 00:33:45.220
kubernetes ok what kind of information you need to provide resource

00:33:45.220 --> 00:33:52.360
information resource limits you need to set the limits for CPU and then the

00:33:52.360 --> 00:33:59.720
memory as a developer of this application you must know because you

00:33:59.720 --> 00:34:05.760
must thoroughly performance test load test your application and then you

00:34:05.760 --> 00:34:13.040
need to benchmark and come up with the values for CPU and memory limit maximum

00:34:13.040 --> 00:34:16.200
CPU and memory your application will continue because you already load

00:34:16.200 --> 00:34:20.640
tested performance tested and you should benchmark that value let's say

00:34:20.640 --> 00:34:29.080
my application won't consume more than 1.5 CPU and memory more than 516 MB

00:34:29.080 --> 00:34:32.300
let's say this is the limit you need to put it in the part

00:34:32.300 --> 00:34:38.180
specification and if you apply to the kubernetes now kubernetes has this

00:34:38.180 --> 00:34:43.740
information and it's going to keep an eye on your container so if your

00:34:43.740 --> 00:34:48.260
container starts to consume more than what is specified on the limit then

00:34:48.820 --> 00:34:52.900
kubernetes will decide that there is something going wrong with this guy

00:34:52.900 --> 00:34:56.800
and kubernetes will take an action the action can be in restart or

00:34:56.800 --> 00:35:01.120
sometimes it will delete and it will create a replacement container okay so

00:35:01.120 --> 00:35:05.020
you will never get into a scenario of this guy eating all the resources

00:35:05.020 --> 00:35:10.480
leaving others starving for the resources that is the limit resource

00:35:10.480 --> 00:35:15.980
limit maximum so this is the case with Lewis who is a beginner he did

00:35:15.980 --> 00:35:20.700
something and he ended up getting this advice from the Hermos who is the

00:35:20.700 --> 00:35:24.160
cluster administrator and now he had deployed the application with this

00:35:24.160 --> 00:35:30.640
input all good Hermos is happy Lewis is happy now we have another case

00:35:30.640 --> 00:35:39.480
this time we have we have Jasper and what he did this he is an expert and

00:35:39.480 --> 00:35:44.640
he wrote some kind of machine learning algorithm and he want to run the

00:35:44.640 --> 00:35:49.740
application in the cluster node 1 node 2 and node 3 and he submits the

00:35:49.740 --> 00:35:56.400
request and the application the container or the part scheduled to run

00:35:56.400 --> 00:36:03.680
in the node 1 but then this part is not starting up it's still not showing

00:36:03.680 --> 00:36:10.360
running status it's in some error status and upon analysis Jasper found

00:36:10.360 --> 00:36:17.720
out that for this container to start up and work it minimum requires 0.5

00:36:17.720 --> 00:36:23.020
CPU and 256 MB of memory but then in this node you don't have that

00:36:23.020 --> 00:36:28.760
resource let's say you have only 100 MB of memory or you don't have you have

00:36:28.760 --> 00:36:35.400
only point to CPU okay so which means and this particular application has

00:36:35.400 --> 00:36:39.640
some minimum resource requirement for it to work minimum resource

00:36:39.640 --> 00:36:44.180
requirement both on CPU and memory that how kubernetes will know there is

00:36:44.180 --> 00:36:47.220
no way that kubernetes will know that unless you provide that

00:36:47.220 --> 00:36:50.400
information to kubernetes as a developer you should know it and you

00:36:50.400 --> 00:36:57.460
provide that information to kubernetes so that while scheduling scheduler will

00:36:57.460 --> 00:37:02.100
consider that while scheduling scheduler will look into your part

00:37:02.100 --> 00:37:05.560
specification and it will understand that okay this is the minimum

00:37:05.560 --> 00:37:09.920
requirement and it won't consider the n1 because n1 doesn't have that

00:37:09.920 --> 00:37:13.820
resource so maybe it will consider the end to entry that will have

00:37:13.820 --> 00:37:17.980
enough resources to to run that container okay so that is the

00:37:17.980 --> 00:37:22.420
minimum resource requirement that that that is required for your application

00:37:22.420 --> 00:37:31.960
to work so that you can specify it under resource request CPU limit 0.5

00:37:31.960 --> 00:37:40.400
CPU 256 MB of memory so resource requests resource limits now you know

00:37:40.400 --> 00:37:45.300
why we need those two so here you can see resource request and resource

00:37:45.300 --> 00:37:50.120
limit okay so as I mentioned this is an time-consuming activity you need to

00:37:50.120 --> 00:37:54.700
perform developers need to perform load balancing and then they need to

00:37:54.700 --> 00:37:59.000
load testing performance testing and they need to come up with these

00:37:59.000 --> 00:38:04.660
values but then if you are running the applications on the cloud we have

00:38:04.660 --> 00:38:11.400
something called VPA vertical part auto scale what it means if you

00:38:11.400 --> 00:38:21.820
configure VPA for your application part then the VPA will observe the CPU and

00:38:21.820 --> 00:38:27.500
memory utilization of your of your application container it will observe

00:38:27.500 --> 00:38:35.380
the values past values and it will recommend the request and limit for

00:38:35.380 --> 00:38:41.980
CPU and memory this VPA component will recommend what to put here instead of

00:38:41.980 --> 00:38:45.280
you are performing a manual benchmarking activity it will observe

00:38:45.280 --> 00:38:50.480
your application over a period of time and based on that hey just set this to

00:38:50.480 --> 00:38:56.760
this this to this this to this value limits and requests it also provides

00:38:58.060 --> 00:39:03.360
an capability where it can automatically set the values also it

00:39:03.360 --> 00:39:08.160
can it can recommend and if you needed you can update it if you configure it

00:39:08.160 --> 00:39:12.340
bit more then this VPA will automatically set the request and

00:39:12.340 --> 00:39:18.040
limits for both CPU and memory time to time both options are possible with

00:39:18.040 --> 00:39:23.380
VPA why I need to do this because it's very important for you to

00:39:23.380 --> 00:39:27.080
right size your application you need to right size your application it

00:39:27.080 --> 00:39:31.680
shouldn't be it should have enough resources for it to work and it

00:39:31.680 --> 00:39:36.500
didn't be eating more resources than what it is required for it right so we

00:39:36.500 --> 00:39:39.380
need to right size the application right size our application in the

00:39:39.380 --> 00:39:45.260
cluster that is more important okay so every specifications that are submitted

00:39:45.260 --> 00:39:52.180
to the cluster you can demand or you can mandate their applications team

00:39:52.180 --> 00:40:01.280
to have this information if not you can simply reject the request as a

00:40:01.840 --> 00:40:06.640
admission controller layer level where you can simply reject the request that

00:40:06.640 --> 00:40:10.740
comes to the cluster without resource request and limits okay and you can

00:40:10.740 --> 00:40:15.860
even automate this if you are in the cloud you can make use of VPA where in

00:40:15.860 --> 00:40:18.980
it will recommend or you can configure it in such a way it will

00:40:18.980 --> 00:40:23.560
automatically set the values how it does it it has access to the matrix

00:40:23.560 --> 00:40:27.240
of your application based on that based on the historical values it

00:40:33.920 --> 00:40:38.340
okay I hope it is clear please let me know if you have any questions before we

00:40:38.340 --> 00:40:42.020
go for a lunch break I'm going to stop here if you have any questions I will

00:40:42.020 --> 00:40:47.740
address it if no then we can go for a lunch break okay after the lunch

00:40:47.740 --> 00:40:52.660
break I will give some time for you to try this no worries is it clear so

00:40:52.660 --> 00:41:01.940
any questions perfect vertical part of scaling up all right time is now 12 20

00:41:01.940 --> 00:41:10.500
so let's take a 45 minutes lunch break and be back by 1 5 p.m. thank you thank

00:41:10.500 --> 00:41:11.480
you for listening

00:41:55.060 --> 00:42:00.860
welcome back welcome back please raise your hands in the teams if you are

00:42:00.860 --> 00:42:09.340
back to a desk just a quick attendance check okay since we are ready to okay

00:42:09.860 --> 00:42:19.620
perfect perfect good we got everyone back I hope you had an great lunch

00:42:19.620 --> 00:42:27.820
time so now it's time to continue our discussion right so I'm going to

00:42:28.480 --> 00:42:36.300
increase the pace of the course a little bit faster right so fine so what

00:42:36.300 --> 00:42:41.980
we completed before the lunch break is we know we now know how to create

00:42:41.980 --> 00:42:48.760
and part using and declarative ml5 creating and part from ml and we

00:42:48.760 --> 00:42:55.320
also learned a couple of probes we have different ways to implement it one is

00:42:55.320 --> 00:43:02.820
using HTTP I think I'm using a wrong pen it should be the pen from me know

00:43:02.820 --> 00:43:08.280
under the parts we learned how to create it with an email under the

00:43:08.280 --> 00:43:16.460
probes we covered different types that is HTTP probe exact probe TCP probe

00:43:16.460 --> 00:43:21.520
there are two different probes that we discussed one is liveness second one is

00:43:21.520 --> 00:43:28.160
readiness if liveness probe fails action is restart if readiness probe

00:43:28.160 --> 00:43:33.500
fails action is don't consider that specific part for load balancing right

00:43:33.500 --> 00:43:39.380
and then from the resources perspective we learn the importance of

00:43:40.430 --> 00:43:48.510
both limit and request this applies for both CPU and memory and in align with

00:43:48.510 --> 00:43:53.990
that we also learned vertical part auto scaling right to automatically set

00:43:53.990 --> 00:43:58.310
values for this or get a recommendation for for the values to be

00:43:58.310 --> 00:44:02.950
set on this limit and request correct so these are all the things

00:44:02.950 --> 00:44:11.170
that we discussed just before our lunch break right so there are a couple of

00:44:11.170 --> 00:44:15.210
other configurations let's talk about that and then I will give some time

00:44:15.210 --> 00:44:19.230
for the hands-on so that you can try it all once in one single example

00:44:19.230 --> 00:44:27.250
right so we know we create an container from the images we have

00:44:27.250 --> 00:44:33.990
images this access and template which means if you create a container this is

00:44:33.990 --> 00:44:38.430
going to get its own file system which means every container will have

00:44:38.430 --> 00:44:42.630
its own file system if you have container to it has its own file

00:44:42.630 --> 00:44:52.610
system isn't it so let's say we have velocity and she tried to spin up a

00:44:53.170 --> 00:45:01.810
for customer database so she choose and postgres image and she is running and

00:45:01.810 --> 00:45:06.530
container are a part based on the postgres image and it's running a

00:45:06.530 --> 00:45:12.630
database and there are many applications that are writing or

00:45:12.630 --> 00:45:17.730
reading the data from this database so this postgres process is going to

00:45:18.010 --> 00:45:24.230
all the data in its file system let's say we have a directory called data

00:45:24.230 --> 00:45:30.350
within the container in a specific folder data you have all those

00:45:30.350 --> 00:45:36.550
millions customer records information about the customers let's say and this

00:45:36.550 --> 00:45:43.810
is working fine what happens is here we have hair moves and he is an

00:45:43.810 --> 00:45:50.950
so what he does is he simply deletes this container let's say mistakenly he

00:45:50.950 --> 00:45:58.230
deleted it so the moment when he deleted the container there is no undo

00:45:58.230 --> 00:46:03.130
for that which means if you delete a container then the file system

00:46:03.130 --> 00:46:07.370
associated with the container it all will also get deleted which means

00:46:07.370 --> 00:46:12.270
you will lose all those million customer records that were in the data

00:46:12.270 --> 00:46:16.870
folder because you deleted the container it goes to any country doesn't need

00:46:16.870 --> 00:46:21.870
to be a database let's say you have an in backend API that generates some

00:46:21.870 --> 00:46:26.870
kind of XML file in a directory for every requested process and if it is

00:46:26.870 --> 00:46:31.130
going to store all those data in this XML directory then if someone

00:46:31.130 --> 00:46:34.050
deletes the container you will lose everything that is there in the

00:46:36.290 --> 00:46:42.230
right so clearly this is not the scenario that we want to face

00:46:43.290 --> 00:46:49.270
basically here the requirement is I have something inside the container

00:46:49.270 --> 00:46:56.390
that I want to possess outside of container lifecycle even if the

00:46:56.390 --> 00:47:01.770
container is deleted I want the data in this directories to be safe okay

00:47:01.770 --> 00:47:07.290
so that is the use case for volumes that's the use case for volumes this is

00:47:07.290 --> 00:47:12.610
the problem that volume concept tries to address so the idea here is simple

00:47:12.610 --> 00:47:19.510
you have your velocities postgres container and all the data is returned

00:47:19.510 --> 00:47:23.970
to the data directory this is the directory you want to possess so what

00:47:23.970 --> 00:47:30.030
I can do is I can choose any location remote location or a local location

00:47:31.390 --> 00:47:40.130
let's say this postgres is running in an host machine host one I can choose a

00:47:40.130 --> 00:47:45.790
path from the host machine let's say there is a path called lax or there is

00:47:45.790 --> 00:47:51.750
a network file share I have a directory here or I have a GC

00:47:51.750 --> 00:47:58.770
persistent disk some some some storage from a cloud or I have azure this

00:47:58.770 --> 00:48:04.850
it can be anywhere so what you can do is you can mount this folders or this

00:48:05.430 --> 00:48:10.710
directories are these volumes you can create a volume in an in an host

00:48:10.710 --> 00:48:16.010
machine path or you can create a volume in an azure disk or you can create a

00:48:16.010 --> 00:48:20.630
volume in a GC persistent disk or create a volume in a network file

00:48:20.630 --> 00:48:25.910
share once the volume is created then you can mount that volume to an

00:48:25.910 --> 00:48:31.030
specific location inside the container so let's say here I am mounting this

00:48:31.030 --> 00:48:36.670
host machine path to the data directory within the container so which means

00:48:36.670 --> 00:48:40.550
whatever the process writes to the data directory it's actually getting

00:48:40.550 --> 00:48:45.510
stored in the lax directory in the host machine so which means if this

00:48:45.510 --> 00:48:50.690
container is deleted the data is still safe in the lax directory okay

00:48:50.690 --> 00:48:55.530
so that I can spin one more new container with the same volume mapping

00:48:55.530 --> 00:49:00.370
so that the new container can see all the data that is left by the previous

00:49:00.370 --> 00:49:09.530
container okay so by this way we are persisting something outside of

00:49:09.530 --> 00:49:13.770
container lifecycle it can be one directly or you may have multiple

00:49:13.770 --> 00:49:18.170
directories that you want to purchase this directory to an NFS this

00:49:19.890 --> 00:49:23.970
doesn't matter based on your requirement you are going to store it in some some

00:49:23.970 --> 00:49:30.330
remote data center or in cloud storage okay so now we know the use case for

00:49:30.330 --> 00:49:36.210
volume and then the problem it addresses correct how to specify that

00:49:36.750 --> 00:49:42.010
volume in your part specification that is our next question in the part

00:49:42.010 --> 00:49:45.010
you have multiple containers at the container level you are going to

00:49:45.270 --> 00:49:52.050
specify all this liveness probe resource request limits even the volumes okay so

00:49:52.050 --> 00:49:58.290
using the volumes is a two-step process first step is you need to define the

00:49:58.290 --> 00:50:01.750
volume and I say define you are going to give a name to the volume and then

00:50:01.750 --> 00:50:07.030
you need to specify the target destination or location where you want

00:50:07.030 --> 00:50:12.250
to create the volume in the host part RNN cloud provider storages so

00:50:12.250 --> 00:50:17.310
that type provider type you need to specify right once the volume is

00:50:17.310 --> 00:50:26.330
defined you need to mount the volume inside the container okay so how to do

00:50:26.330 --> 00:50:31.070
that the step number one is defining the volume isn't it so in the same

00:50:31.070 --> 00:50:37.410
intention as containers you can see we define the volume the name of the

00:50:37.410 --> 00:50:41.150
volume and then where you are going to create the volume in a network

00:50:41.150 --> 00:50:45.130
file share this is the server name this is the part in that NFS you can

00:50:45.130 --> 00:50:49.430
even provide more configurations like how much space you want to block and so

00:50:49.430 --> 00:50:54.130
on so details but keeping it simple this is how it's going to be in a

00:50:54.130 --> 00:50:57.250
network file share you are going to create a volume with the name as an

00:50:57.250 --> 00:51:01.130
core data remaining properties are defaults that's going to get applied

00:51:01.130 --> 00:51:07.550
right so step one is defining defining the volume and step two is

00:51:07.710 --> 00:51:14.350
mounting this volume inside the container path or a directory so that

00:51:14.350 --> 00:51:20.270
you can see it under container specification under containers we have

00:51:20.790 --> 00:51:25.910
volume mounts and here you are specifying the name of the volume and

00:51:26.470 --> 00:51:31.750
then the mount path this is the path inside this container that is in this

00:51:33.170 --> 00:51:39.090
data directory it will get mounted with this volume so which means whatever

00:51:39.090 --> 00:51:43.210
the application writes to the data directory it will go all the way to

00:51:43.210 --> 00:51:49.310
this network file share export directory okay defining the volume is

00:51:49.310 --> 00:51:57.230
part one and using or mounting that volume to a path inside the

00:51:58.350 --> 00:52:03.750
using volume mounts is the step number two okay so later on day two we are

00:52:03.750 --> 00:52:10.770
going to see how we are going to refactor this logic to move to

00:52:10.770 --> 00:52:15.250
persistent volume and persistent volume claims what is the what is the

00:52:15.250 --> 00:52:19.170
problem or the challenge with this way of defining the volume compared to

00:52:19.170 --> 00:52:24.870
using PV and PVC right but pretty much this does the job using volume and

00:52:26.290 --> 00:52:33.070
okay so if you look at and production grade what specification these are all

00:52:33.070 --> 00:52:40.730
the things that you will always see one is the the image specifications the

00:52:40.730 --> 00:52:45.070
application specific things and then resource request and limits liveness

00:52:45.070 --> 00:52:50.450
probe readiness probe volume mounts we are yet to see secret mass and

00:52:50.450 --> 00:52:55.190
you will also see many specifications related to injecting some

00:52:55.190 --> 00:53:02.950
configurations right that's it so this is for the NFS I don't think I have a

00:53:02.950 --> 00:53:06.710
server with this name you can also replace it with the host path let's

00:53:06.710 --> 00:53:14.790
say you want to mount a path from a host machine then there is one type

00:53:14.790 --> 00:53:21.610
called host path and then to the type you are going to specify the path in the

00:53:21.610 --> 00:53:28.250
host machine let me open this file yep as you can see here it uses and type

00:53:28.250 --> 00:53:33.170
as an host path the path in the host machine and then mounting that volume

00:53:33.170 --> 00:53:39.510
to the data directory okay there are many supported storage provided types

00:53:39.510 --> 00:53:46.150
that again we will discuss while we talk about persistent volumes right but

00:53:46.150 --> 00:53:49.850
now we are clear with the workflow what it all takes to create a volume and

00:53:49.850 --> 00:54:00.830
then mount it inside a folder okay so with this we now know in addition to

00:54:00.830 --> 00:54:04.670
this resource request and limit what it all takes to configure the

00:54:07.090 --> 00:54:12.170
volumes defining the volume and then mounting that volume inside a container

00:54:12.170 --> 00:54:19.490
those two steps okay please feel free to stop if you have any questions so

00:54:19.490 --> 00:54:24.110
now I think now we are getting more clarity on what all the things that

00:54:24.110 --> 00:54:29.150
we can do at the pod level itself isn't it so if you still remember I

00:54:29.150 --> 00:54:33.550
mentioned about multi container part there are some use cases for

00:54:33.550 --> 00:54:39.630
multi container part so let me talk about a bit here right so the first

00:54:39.630 --> 00:54:44.230
scenario that I'm going to talk about is unit containers this is there to

00:54:44.230 --> 00:54:48.750
serve a specific purpose for example this is your main container a

00:54:49.550 --> 00:54:55.290
container that runs your business application and we will also run one

00:54:55.290 --> 00:55:01.150
or more unit containers the purpose of the unit container is as the names

00:55:01.150 --> 00:55:10.070
it's for executing some initialization logics or in other terms setting the

00:55:10.070 --> 00:55:15.350
stage for the main container to run so based on your application you may have

00:55:15.350 --> 00:55:21.030
some complex initialization logic like mounting and volume or creating

00:55:21.030 --> 00:55:24.730
checking some dependencies there are a lot of initialization logic that you

00:55:24.730 --> 00:55:29.150
want to check so instead of having those initialization logic as part of

00:55:29.150 --> 00:55:34.310
main container you can have it in the unit containers you can have one or more

00:55:34.310 --> 00:55:39.830
unit containers and for the containers we define like containers and

00:55:39.830 --> 00:55:43.990
then we define the first container right similarly for the unit

00:55:43.990 --> 00:55:49.190
containers we have and separate attribute like the same indentation as

00:55:49.190 --> 00:55:52.710
continuous you will defend any containers and you will give the first

00:55:52.710 --> 00:55:57.110
unit container second unit container third unit container like this so it's

00:55:57.110 --> 00:56:01.930
not like you will put it here that's that's that's meant for different pattern

00:56:01.930 --> 00:56:06.070
that we are going to discuss like sidecar you will run it but in it

00:56:06.070 --> 00:56:11.370
containers it has its own life cycle which means if you have it in it

00:56:11.370 --> 00:56:16.350
container defined it will execute in the same order that you defined here

00:56:16.350 --> 00:56:21.930
one by one first this container will execute it will run to its entirety

00:56:21.930 --> 00:56:27.770
and then it should exit with an success code completely it should execute

00:56:27.770 --> 00:56:33.310
successfully maybe it has some set of commands to execute and then the

00:56:33.310 --> 00:56:36.970
second unit continuous but must execute successfully third unit

00:56:36.970 --> 00:56:42.250
container must execute successfully if all the unit containers completed

00:56:42.250 --> 00:56:47.470
basically is going to have some short lived set of commands to perform if

00:56:47.470 --> 00:56:51.570
it all successfully executed that's the time the main container will start

00:56:52.390 --> 00:56:58.490
because the stage is ready now the hero can enter right so if it's one of the

00:56:58.490 --> 00:57:02.930
initialization container fails then the entire part will be restarted again

00:57:02.930 --> 00:57:08.410
from first container second category third category execute so that's the

00:57:08.410 --> 00:57:13.830
behavior of unit containers let me include this links in the etherpad so

00:57:13.830 --> 00:57:19.410
that it will be easy for you to refer in it containers eight containers

00:57:19.410 --> 00:57:23.990
always runs to completion each unit container must complete successfully

00:57:23.990 --> 00:57:28.650
before the next one starts and this unit containers it doesn't support

00:57:28.650 --> 00:57:35.330
liveness probe readiness probe bar so on so because it's it's not the long

00:57:35.330 --> 00:57:40.450
running process this is that to just set the stage for the main guy and

00:57:41.430 --> 00:57:46.510
the way to define it as you can see here as like containers we have any

00:57:46.510 --> 00:57:53.750
section this application has two unit containers and here it you can see

00:57:53.750 --> 00:57:59.890
here it checks whether the my service my service is already available in the

00:57:59.890 --> 00:58:03.250
cluster so it's going to wait it's just checking one of the dependent

00:58:03.250 --> 00:58:06.890
service is already up and running or not this is checking for the database

00:58:06.890 --> 00:58:10.490
this is checking for a service if it is already available then this will

00:58:10.490 --> 00:58:14.450
succeed this will succeed then the main container will start maybe the

00:58:14.450 --> 00:58:20.250
main container is as part of his initialization logic it may want to

00:58:20.250 --> 00:58:25.250
communicate with my service and my DB so if these two are not up then if it

00:58:25.250 --> 00:58:30.270
spins up it may fail so in this case they are using the unit containers to

00:58:30.270 --> 00:58:35.810
make sure those two services are available and then it does right so

00:58:35.810 --> 00:58:39.090
this happens only during the startup time once unit containers are

00:58:39.090 --> 00:58:43.990
executed and started up and the main category started up then it

00:58:43.990 --> 00:58:50.010
won't execute again maybe in the next to start it will execute okay so which

00:58:50.010 --> 00:58:54.210
means after main container is up and running if the my service container

00:58:54.210 --> 00:59:00.770
goes down then this this this is not responsible for that okay I think you

00:59:00.770 --> 00:59:05.150
got that idea right so this is just for the initialization logic as

00:59:05.750 --> 00:59:14.370
okay so I also mentioned about sidecar patterns right car sidecar cycle that

00:59:14.370 --> 00:59:26.770
is the given as documentation okay that's fine I can explain it from here

00:59:26.770 --> 00:59:31.270
so this is one case for multi-container part other cases in the

00:59:31.530 --> 00:59:37.390
containers array you are going to define the first container and then the

00:59:37.390 --> 00:59:41.370
second container here there is nothing like an order like this should execute

00:59:41.370 --> 00:59:45.090
and this should execute both will run parallel this is going to be a long

00:59:45.090 --> 00:59:48.950
running process this is also going to be a long running process this is the

00:59:48.950 --> 00:59:53.190
specification for main container this is the specification for a sidecar

00:59:53.190 --> 00:59:58.050
and this is here to provide some helper functionality one of the

00:59:58.250 --> 01:00:03.470
functionalities you have a main container and you have let's say and

01:00:03.470 --> 01:00:09.090
logging back in and your application is generating a logs in an ABC format

01:00:09.090 --> 01:00:16.290
but you are logging back and expects the log in an XYZ format so what I

01:00:16.290 --> 01:00:21.510
can do is I can run a sidecar maybe the main application is writing to an

01:00:21.510 --> 01:00:27.330
volume and this sidecar can read the log from the volume transform the

01:00:27.330 --> 01:00:33.110
ABC format to XYZ format and it can even forward the log to the logging

01:00:33.110 --> 01:00:39.890
packet so in this case this sidecar does two operation one transforming the

01:00:40.610 --> 01:00:46.910
logging from ABC to XYZ format and then forwarding the log to the logging

01:00:46.910 --> 01:00:52.770
packet so this is just one helper functionality so in this case what

01:00:52.770 --> 01:01:00.130
does is an adapter pattern so this is an adapter sidecar because the target

01:01:00.130 --> 01:01:03.390
system experts in a different format the source generates in a different

01:01:03.390 --> 01:01:09.190
format so this access and kind of adapter between these two okay one case

01:01:09.190 --> 01:01:12.850
where we will use the sidecar and there is another case let's say the

01:01:12.850 --> 01:01:20.550
same main I have and here I have an external and web service from my

01:01:20.550 --> 01:01:28.270
party vendor and dealing with the external web service which means there

01:01:28.270 --> 01:01:33.910
is a separate authentication mechanism if service is not available retry

01:01:33.910 --> 01:01:40.690
patterns circuit breaker patterns and implementing some kind of fallback

01:01:40.690 --> 01:01:44.630
mechanisms there are a lot of things that I need to handle at the main

01:01:44.630 --> 01:01:49.390
container to call this service and working with this external service so

01:01:49.390 --> 01:01:54.350
instead of having all those logics in the main container how about creating

01:01:54.350 --> 01:01:59.670
an sidecar and offloading all the responsibilities to here so that as a

01:01:59.670 --> 01:02:03.650
main container I will simply call it as an local host as like any local

01:02:03.650 --> 01:02:07.410
method I will call this method and this is going to take care of dealing

01:02:07.410 --> 01:02:12.210
with this external service all the authentication retry circuit breaker

01:02:12.210 --> 01:02:16.870
logic it's all resides here so in this case this is kind of acts as an

01:02:16.870 --> 01:02:24.110
proxy this sidecar acts as a proxy for this external web service so this

01:02:24.110 --> 01:02:27.330
pattern we call it as an ambassador pattern this is also providing a

01:02:27.330 --> 01:02:30.690
helper functionality but the cases are different for these two scenarios

01:02:30.690 --> 01:02:37.750
okay and always keep in mind that if you are going to schedule a part let

01:02:37.750 --> 01:02:44.050
say velocity she is going to schedule a part with two containers or

01:02:44.050 --> 01:02:52.090
containers one main and two sidecar and in the kubernetes cluster if if this

01:02:52.090 --> 01:02:56.030
part is scheduled to run in a node number two then all the containers

01:02:56.030 --> 01:03:00.590
will run in the same node only that is the characteristics of part right

01:03:00.590 --> 01:03:06.050
because all these containers can reach to one another via IPC inter process

01:03:06.050 --> 01:03:10.010
communication which means as can call this as an local host and then hit

01:03:10.010 --> 01:03:15.290
the port number dish to it this can call this as a local host right so

01:03:15.290 --> 01:03:20.790
which means all the containers in that part will always land in the same

01:03:20.790 --> 01:03:24.570
node it not like see one will run here see two will run here see three

01:03:24.570 --> 01:03:28.790
will run here that is not the case all the containers within the part

01:03:28.790 --> 01:03:34.510
specification will always land in the same node okay just keep that in

01:03:34.510 --> 01:03:42.990
mind all right so fit these discussions are part topic comes to an end we deep

01:03:42.990 --> 01:03:47.930
dived into the part we we learned the part lifecycle commands different things

01:03:47.930 --> 01:03:51.990
that will be there in the part specification and then the use cases

01:03:51.990 --> 01:03:57.010
for multi-container parts with this I am going to give a quick pass you can

01:03:57.010 --> 01:04:02.070
directly try the 1 6 part fully aml file that has all the concepts in it

01:04:02.270 --> 01:04:09.430
you can try it or you can spend some time to go through the specifications go

01:04:09.430 --> 01:04:13.450
through the documentations I'm going to give you here a 10 to 15 minutes let's

01:04:13.450 --> 01:04:18.670
say after that you will move to the next resource that is replica set and

01:04:18.670 --> 01:04:22.410
deployments is this clear guys are you good with the pace is it all

01:04:22.410 --> 01:04:27.650
clear I need few confirmations please okay thank you please okay go ahead

01:04:27.650 --> 01:04:28.130
please