Hi, Let's understand how to leverage the hook weight
when I'm having multiple hooks for the same stage. I'll be creating multiple hooks with preinstalled
stage where it will be having different weights. Based on the weights
It's going to get triggered so that it will not have any confusion on which hook should get triggered
first and which one to get triggered in the last.
So let me go ahead and create a couple of yaml files.
Let me get into the folder templates and remove the earlier yaml files.
Now I'm going to create three yaml files all of type preinstalled hook. Let me add the content.
So it's of kind job where it is going to have annotation it is a hook.
It will get triggered in preinstalled state and hook weight is minus two.
I'm going to add another yaml file
Let me add content to the same. It's the same content.
Only the Echo statement is different and the sleep seconds are different.
Now, I'm changing the weight as well. In this case, the weight is three.
Now, let me add another yaml file. I'm adding the content to it. Here
The weight is five, and the stage when hook will get triggered is preinstalled.
So I do have three hooks, all of type preinstalled having different weights.
Now, let me go ahead and install this particular chart.
Let me check is there any deployment. I do not have any deployment.
Only one which was used earlier. I'll leave it as it is.
Now, let me go ahead and do the installation of this specific chart helm install
name of the chart and the chart folder hooktest. So it got over.
Now let me go ahead and get the status about the pods kubectl get pods
So I do have three pods in the completed state. That is hook one, two and three.
And let me go ahead and check the execution time of these pods, rather than seeing the pods individually
I can go ahead and get the description about all the pods and grep only the name, annotation, started and finished time.
In this case, I am worried only about these three hooks.
That is hook one, hook two and hook three. If you observe very carefully
Hook one started in 31st second got over in 33.
Hook two started afterwards that is 37 and got over at 40.
Then hook three got started and it started at 44 and got over at 49th second.
that means the weightage with less number going to get executed first
And the one with the weightage of high number will get executed later.
This is a good example on how to use the weightage when I do have multiple hooks so that the system will
not have confusion on which hook to pick when it needs to execute multiple hooks for the same stage.
Let me go ahead and remove the deployments
helm delete name of the deployment and delete all the three jobs hook one, hook two and hook three.
Let me make sure there are no pods running and nothing in helm list.
Yes, No additional deployments within helm.
So in a quick summary we discussed about how to use the hook weightage when we do have multiple hooks for the same stage.