Monitoring a kubernetes job

trial999 picture trial999 · Aug 25, 2016 · Viewed 15.8k times · Source

I have kubernetes jobs that takes variable amount of time to complete. Between 4 to 8 minutes. Is there any way i can know when a job have completed, rather than waiting for 8 minutes assuming worst case. I have a test case that does the following:

1) Submits the kubernetes job.
2) Waits for its completion.
3) Checks whether the job has had the expected affect.

Problem is that in my java test that submits the deployment job in the kubernetes, I am waiting for 8 minutes even if the job has taken less than that to complete, as i dont have a way to monitor the status of the job from the java test.

Answer

Vojtech Vitek picture Vojtech Vitek · Aug 16, 2019
$ kubectl wait --for=condition=complete --timeout=600s job/myjob