Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Time based container scheduling on Kubernetes?

What is the recommended way to execute a container or pod based on a time-based schedule? For example, a task to run at 2am for 10 minutes every day.

On a traditional linux server, crontab would easily work, and that obviously still is possible inside the container. However, since this task only executes for 10 minutes I was looking for a mechanism to execute a basic container on a given time interval, then dispose of of the container.

Chronos (part of Mesos) appears to have a similar behavior, is this possible in Container Engine?

like image 526
TimK Avatar asked Jul 10 '15 20:07

TimK


People also ask

How does scheduling work in Kubernetes?

The Kubernetes scheduler is a control plane process which assigns Pods to Nodes. The scheduler determines which Nodes are valid placements for each Pod in the scheduling queue according to constraints and available resources. The scheduler then ranks each valid Node and binds the Pod to a suitable Node.


4 Answers

This is expected to be supported in 1.3: https://github.com/kubernetes/kubernetes/pull/11980

UPDATE:

didn't meet the 1.3 deadline so it'll sleep into 1.4

https://github.com/kubernetes/kubernetes/issues/2156#issuecomment-223385808

UPDATE (thanks @Kevinoid): Looks like it has reached alpha in 1.4 and progress is now being tracked in https://github.com/kubernetes/features/issues/19 with usage documentation at http://kubernetes.io/docs/user-guide/cron-jobs/

like image 142
Jesús Carrera Avatar answered Oct 18 '22 22:10

Jesús Carrera


Unfortunately, there isn't currently support for cron jobs in Kubernetes or Container Engine. The Github Issue tracking it is here, if you'd like to share ideas for what features it should have or express your interest in it!

like image 4
Alex Robinson Avatar answered Oct 18 '22 21:10

Alex Robinson


A work around for now would be to use a run-once Pod and add kubectl to your cron tab on a machine.

e.g. add

kubectl create -f <run-once-pod>

to your cron tab.

like image 3
Brendan Burns Avatar answered Oct 18 '22 20:10

Brendan Burns


Seems like "Cron Jobs" (since 1.4) is the answer: http://kubernetes.io/docs/user-guide/cron-jobs/

like image 1
Slava V Avatar answered Oct 18 '22 22:10

Slava V