1
00:00:00,000 --> 00:00:06,966
Hi, Let's understand how to leverage the hook weight

2
00:00:06,966 --> 00:00:14,199
when I'm having multiple hooks for the same stage. I'll be creating multiple hooks with preinstalled

3
00:00:14,200 --> 00:00:18,100
stage where it will be having different weights. Based on the weights

4
00:00:18,100 --> 00:00:23,866
It's going to get triggered so that it will not have any confusion on which hook should get triggered

5
00:00:23,866 --> 00:00:27,466
first and which one to get triggered in the last.

6
00:00:27,466 --> 00:00:30,399
So let me go ahead and create a couple of yaml files.

7
00:00:30,400 --> 00:00:44,066
Let me get into the folder templates and remove the earlier yaml files.

8
00:00:44,066 --> 00:00:52,366
Now I'm going to create three yaml files all of type preinstalled hook. Let me add the content.

9
00:00:52,366 --> 00:00:56,766
So it's of kind job where it is going to have annotation it is a hook.

10
00:00:56,766 --> 00:01:03,199
It will get triggered in preinstalled state and hook weight is minus two.

11
00:01:03,200 --> 00:01:09,433
I'm going to add another yaml file

12
00:01:09,433 --> 00:01:13,166
Let me add content to the same. It's the same content.

13
00:01:13,166 --> 00:01:18,466
Only the Echo statement is different and the sleep seconds are different.

14
00:01:18,466 --> 00:01:24,899
Now, I'm changing the weight as well. In this case, the weight is three.

15
00:01:24,900 --> 00:01:31,033
Now, let me add another yaml file. I'm adding the content to it. Here

16
00:01:31,033 --> 00:01:36,866
The weight is five, and the stage when hook will get triggered is preinstalled.

17
00:01:36,866 --> 00:01:41,866
So I do have three hooks, all of type preinstalled having different weights.

18
00:01:41,866 --> 00:01:47,232
Now, let me go ahead and install this particular chart.

19
00:01:47,233 --> 00:01:50,533
Let me check is there any deployment. I do not have any deployment.

20
00:01:50,533 --> 00:01:55,399
Only one which was used earlier. I'll leave it as it is.

21
00:01:55,400 --> 00:02:00,000
Now, let me go ahead and do the installation of this specific chart helm install

22
00:02:00,000 --> 00:02:06,400
name of the chart and the chart folder hooktest.
So it got over.

23
00:02:06,400 --> 00:02:13,000
Now let me go ahead and get the status about the pods kubectl get pods

24
00:02:13,000 --> 00:02:18,400
So I do have three pods in the completed state.
That is hook one, two and three.

25
00:02:18,400 --> 00:02:25,533
And let me go ahead and check the execution time of these pods, rather than seeing the pods individually

26
00:02:25,533 --> 00:02:34,566
I can go ahead and get the description about all the pods and grep only the name, annotation, started and finished time.

27
00:02:34,566 --> 00:02:37,132
In this case, I am worried only about these three hooks.

28
00:02:37,133 --> 00:02:42,533
That is hook one, hook two and hook three. If you observe very carefully

29
00:02:42,533 --> 00:02:46,866
Hook one started in 31st second got over in 33.

30
00:02:46,866 --> 00:02:51,699
Hook two started afterwards that is 37 and got over at 40.

31
00:02:51,700 --> 00:02:59,400
Then hook three got started and it started at 44 and got over at 49th second.

32
00:02:59,400 --> 00:03:05,400
that means the weightage with less number going to get executed first

33
00:03:05,400 --> 00:03:10,500
And the one with the weightage of high number will get executed later.

34
00:03:10,500 --> 00:03:16,166
This is a good example on how to use the weightage when I do have multiple hooks so that the system will

35
00:03:16,166 --> 00:03:24,332
not have confusion on which hook to pick when it needs to execute multiple hooks for the same stage.

36
00:03:24,333 --> 00:03:27,699
Let me go ahead and remove the deployments

37
00:03:27,700 --> 00:03:41,300
helm delete name of the deployment and delete all the three jobs hook one, hook two and hook three.

38
00:03:41,300 --> 00:03:47,566
Let me make sure there are no pods running and nothing in helm list.

39
00:03:47,566 --> 00:03:51,132
Yes, No additional deployments within helm.

40
00:03:51,133 --> 00:03:59,299
So in a quick summary we discussed about how to use the hook weightage when we do have multiple hooks for the same stage.

