Hi, In the earlier lecture we discussed about how to use the pre-install and post-install Hook the
same way I can have the hooks for the jobs of kubernetes as well.
Let's see through an example.
Let me get into the same chart that we had created.
Within that, I'm going to get into the templates folder and remove the yaml file that we had created.
Now I'm going to create pre-install post-install hook for the jobs.
Let me go ahead and create a yaml file and add content to this.
So here again, I have added the annotation.
It's a hook and added the stage when it should get triggered as pre-install.
And I do have the kind as job
So this is going to get executed as a job where it's going to echo this particular statement and sleep
for five seconds. The same way
Let me go ahead and create another yaml file post install job hook and add content to this.
I have mentioned the annotation as it's a hook and the stage when it should get triggered as post-install.
So I do have both the yaml file as a part of the template.
Let me go ahead and install the chart using the helm install command helm install hook test job install
and then the name of the folder. That job should get over.
Now let me go ahead and check the entities within the kubernetes.
So if I look at there are two pods that got over that is pre-install pod and post-install hook pod
which got triggered by these two jobs and
The other pod that is continuing to run, that is the actual pod that we do have within the templates.
So this particular hook is going to get executed as a job and the earlier one that was getting executed
as a pod directly. In this case I will be in a position to control how many times it should get triggered
as well as I will be in a position to harvest, all the features available within the jobs as well.
So this works very similar to how we had the hook as a part of the pods.
Now, let me go ahead and check the details on how this got executed.
Let me get the Pre-install pod name.
Let me describe the pod
So this got started in 17th second and got over in 22nd second.
Now I'm going to get the actual pod. So that started in twenty sixth second.
Now let me get the post install hook pod.
That started its execution at 26th second and got over in 36th second.
This is a quick example on how a job can be invoked as a hook using the pre-install and post-install hook.
Let me go ahead and clean up the system.
First, let me delete the helm installation and delete the jobs.
cubectl delete job/preinstall job and postinstall job
Let me get the entities within the kubernetes cluster.
I do not have the completed pods as well because when I'm deleting the jobs automatically the
completed pods will also get deleted.
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.