How do you create a Kubernetes job job1 with image busybox that will be executed 3 times and maximum of 2 job instances will run in parallel? The command executed in a job should be sleep 10 && echo "Hello world"

Experience Level: Medior
Tags: Kubernetes

Answer

Run the following command:

kubectl create job job1 --image=busybox --dry-run=client -o yaml -- /bin/sh -c "sleep 10 && echo 'Hello world'" > job.yaml

Edit the job.yaml by running the following command:

nano job.yaml

Add the following fields to spec:

parallelism: 3
completions: 2

Save the file and run the following:

kubectl apply -f job.yaml

Comments

No Comments Yet.
Be the first to tell us what you think.
Kubernetes Certified Application Developer (CKAD) preparation
Kubernetes Certified Application Developer (CKAD) preparation

Are you learning Kubernetes ? Try our test we designed to help you progress faster.

Test yourself
Kubernetes
Kubernetes

Are you learning Kubernetes ? Try our test we designed to help you progress faster.

Test yourself
Kubernetes Certified Administrator (CKA) preparation
Kubernetes Certified Administrator (CKA) preparation

Are you learning Kubernetes ? Try our test we designed to help you progress faster.

Test yourself