Confusion about how to update kubernetes jobs

4/26/2016

I am eagerly awaiting the release of Kubernetes v1.3 in mid to late June, so that I can access cron scheduling for jobs. In the meantime, what I plan to do is the following:

  • Deploy a job on my Kubernetes cluster
  • Use jenkins as a cron tool to trigger the job in defined intervals (e.g. 1 hour).

I have two questions:

How do I update a job? For replication controllers, I would simply do a rolling update, but in the jobs API spec (http://kubernetes.io/docs/user-guide/jobs/) there are no details about how to do this. For example, lets say that I want to use my jenkins deploy system to update the job whenever I do a git commit.

Is it possible to use the kubernetes API to trigger jobs? For example, I have a job that runs and then the pod is terminated on completion. Then, 1 hour later, I want to use jenkins to trigger the job again.

Thanks so much!

-- Zach
job-scheduling
kubernetes

1 Answer

5/3/2016

I am not sure if there is any fancy way to trigger a completed job, but one way to do it can be to delete and recreate the job.

Re: rolling-update: that is required for long running pods, which is what RCs control. For jobs: You can update the podTemplateSpec in jobSpec and that will ensure that any new pod created by the job after the update will have the updated podTemplateSpec (note: already running pods will not be affected).

Hope this helps!

-- Nikhil Jindal
Source: StackOverflow