1
00:00:00,000 --> 00:00:09,466
Hi, In the earlier lecture we discussed about how to use the pre-install and post-install Hook the

2
00:00:09,466 --> 00:00:14,299
same way I can have the hooks for the jobs of kubernetes as well.

3
00:00:14,300 --> 00:00:16,366
Let's see through an example.

4
00:00:16,366 --> 00:00:19,999
Let me get into the same chart that we had created.

5
00:00:20,000 --> 00:00:30,800
Within that, I'm going to get into the templates folder and remove the yaml file that we had created.

6
00:00:30,800 --> 00:00:36,100
Now I'm going to create pre-install post-install hook for the jobs.

7
00:00:36,100 --> 00:00:44,933
Let me go ahead and create a yaml file and add content to this.

8
00:00:44,933 --> 00:00:47,566
So here again, I have added the annotation.

9
00:00:47,566 --> 00:00:53,032
It's a hook and added the stage when it should get triggered as pre-install.

10
00:00:53,033 --> 00:00:55,399
And I do have the kind as job

11
00:00:55,400 --> 00:01:01,400
So this is going to get executed as a job where it's going to echo this particular statement and sleep

12
00:01:01,400 --> 00:01:04,666
for five seconds. The same way

13
00:01:04,666 --> 00:01:13,066
Let me go ahead and create another yaml file post install job hook and add content to this.

14
00:01:13,066 --> 00:01:20,399
I have mentioned the annotation as it's a hook and the stage when it should get triggered as post-install.

15
00:01:20,400 --> 00:01:23,666
So I do have both the yaml file as a part of the template.

16
00:01:23,666 --> 00:01:32,732
Let me go ahead and install the chart using the helm install command helm install hook test job install

17
00:01:32,733 --> 00:01:40,966
and then the name of the folder. That job should get over.

18
00:01:40,966 --> 00:01:48,099
Now let me go ahead and check the entities within the kubernetes.

19
00:01:48,100 --> 00:01:56,100
So if I look at there are two pods that got over that is pre-install pod and post-install hook pod

20
00:01:56,100 --> 00:02:00,900
which got triggered by these two jobs and

21
00:02:00,900 --> 00:02:09,032
The other pod that is continuing to run, that is the actual pod that we do have within the templates.

22
00:02:09,032 --> 00:02:14,899
So this particular hook is going to get executed as a job and the earlier one that was getting executed

23
00:02:14,900 --> 00:02:21,333
as a pod directly. In this case I will be in a position to control how many times it should get triggered

24
00:02:21,333 --> 00:02:27,633
as well as I will be in a position to harvest, all the features available within the jobs as well.

25
00:02:27,633 --> 00:02:33,466
So this works very similar to how we had the hook as a part of the pods.

26
00:02:33,466 --> 00:02:38,266
Now, let me go ahead and check the details on how this got executed.

27
00:02:38,266 --> 00:02:41,399
Let me get the Pre-install pod name.

28
00:02:41,400 --> 00:02:43,266
Let me describe the pod

29
00:02:43,266 --> 00:02:48,899
So this got started in 17th second and got over in 22nd second.

30
00:02:48,900 --> 00:02:56,633
Now I'm going to get the actual pod. So that started in twenty sixth second.

31
00:02:56,633 --> 00:03:02,866
Now let me get the post install hook pod.

32
00:03:02,866 --> 00:03:07,966
That started its execution at 26th second and got over in 36th second.

33
00:03:07,966 --> 00:03:15,866
This is a quick example on how a job can be invoked as a hook using the pre-install and post-install hook.

34
00:03:15,866 --> 00:03:18,399
Let me go ahead and clean up the system.

35
00:03:18,400 --> 00:03:25,066
First, let me delete the helm installation and delete the jobs.

36
00:03:25,066 --> 00:03:31,599
cubectl delete job/preinstall job and postinstall job

37
00:03:31,600 --> 00:03:35,600
Let me get the entities within the kubernetes cluster.

38
00:03:35,600 --> 00:03:40,700
I do not have the completed pods as well because when I'm deleting the jobs automatically the

39
00:03:40,700 --> 00:03:44,166
completed pods will also get deleted.

40
00:03:44,166 --> 00:03:52,932
So in a quick summary we learnt about how to use a job as a hook to get triggered as a part of pre-install and post install stages.

