The simplest use case for a job is to launch a single pod and ensure that it successfully runs to completion.
In our next example, we are going to use the Ruby programming language to compute and print out the first 100 Fibonacci numbers:
fib.yaml
apiVersion: batch/v1
kind: Job
metadata:
name: fib
spec:
template:
metadata:
name: fib
spec:
containers:
- name: fib
image: ruby:alpine
command: ["ruby"]
args:
- -e
- |
a,b = 0,1
100.times { puts b = (a = a+b) - b }
restartPolicy: Never
Notice that the contents of spec and template are very similar to the specification we used to launch a pod directly. When we define a pod template for use in a job, we need to choose a restartPolicy of Never or OnFailure.
The reason for this is that the end goal of a job is to run the pod until it...