Kubernetes cronjob : execute multiples tasks each one take different file as argument

4/14/2020

I want to launch a cronjob in k8s. the equivalent crontab is :

* * * * * python3 my_script.py -p params_1.json 
* * * * * python3 my_script.py -p params_2.json 
* * * * * python3 my_script.py -p params_3.json 

i try using cronjob but i don't know how to make the cronjob take each param_i.json in separate task.

any idea ? do i need a cronjob instance for each line above or i can manage that with just one cronjob instance ?

Thanks for your help

-- abk
cron
kubernetes
openshift
parallel-processing

1 Answer

4/14/2020

A Cronjob creates a Pod which can hold multiple Containers. Each Container could perform one of your tasks but they would run in parallel and maybe canceled if one Container fails (Exit Code != 0).

The best solution would either to create one Cronjob per Job you want to do or running the Jobs in one Container, one by one.

-- Alex
Source: StackOverflow