Menu
Coddy logo textTech

Jobs

Part of the Introduction to Kubernetes section of Coddy's Terminal journey. Lesson 32 of 45.

Not everything should run forever. A report, a backup or a one-off script should run once and stop. For that Kubernetes has the Job: it runs a Pod until the command finishes successfully, and does not restart it afterwards.

Create a Job with an image and a command:

kubectl create job hello --image=busybox -- echo "job done"

Kubernetes answers job.batch/hello created. kubectl get jobs shows its COMPLETIONS, going from 0/1 to 1/1.

The Job's Pod appears in kubectl get pods with a generated name and ends in the status Completed rather than being restarted. Its output is kept, and you can read it by naming the Job:

kubectl logs job/hello
challenge icon

Challenge

Easy

Create a Job named hello from the busybox image running echo "job done". List the Jobs, list the Pods twice to see the Pod reach Completed, then read the Job's logs.

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Introduction to Kubernetes

Practice on your own: Terminal playground