Hi I want to create multiple pods (with different command and args) in a job and . . .

Prince Bansal:
Hi
I want to create multiple pods (with different command and args) in a job and want to run them in parallel. I am not able to understand how I can declare object definition with multiple pods.

Sangeetha Radhakrishnan:
Hi Prince,
Do you want to achieve this using in a single job? or more than one job can be acceptable?

Sangeetha Radhakrishnan:
if you want to achieve this in a single job, use job index to execute different commands. How to create indexed Job refer : https://kubernetes.io/docs/tasks/job/indexed-parallel-processing-static/

Prince Bansal:
@Sangeetha Radhakrishnan More than 1 job can be acceptable.

Prince Bansal:
This feature is in alpha.
FEATURE STATE: Kubernetes v1.21 [alpha]
I want to run it in production environment.
And server version is: Server Version: v1.18.14

Please suggest the same to achieve same in 1.18.4 k8 version ?

unnivkn:
Running Automated Tasks with a CronJob
CronJobs was promoted to general availability in Kubernetes v1.21. If you are using an older version of Kubernetes, please refer to the documentation for the version of Kubernetes that you are using, so that you see accurate information. Older Kubernetes versions do not support the batch/v1 CronJob API.
You can use a https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/|CronJob to run https://kubernetes.io/docs/concepts/workloads/controllers/job/|Jobs on a time-based schedule. These automated jobs run like https://en.wikipedia.org/wiki/Cron|Cron tasks on a Linux or UNIX system.

unnivkn:
Hi i am not sure about your senario. If it is older version please try to create multiple cronjobs having single pod and schedule all at the same time.

If Cronjob not supports then the option is to create multiple jobs and schedule it through linux cron to run at the same time.

controlplane $ k apply -f 10.yaml
error: unable to recognize “10.yaml”: no matches for kind “CronJob” in version “batch/v1”
controlplane $

controlplane $ k apply -f 10.yaml
cronjob.batch/hello created
controlplane $

controlplane $ cat 10.yaml | grep -i apiVersion
apiVersion: batch/v1beta1
controlplane $

controlplane $ kubectl version --short
Client Version: v1.20.0
Server Version: v1.20.0
controlplane $

Prince Bansal:
Thanks for the help guys.