apiVersion: batch/v1
kind: Job
metadata:
  name: math-add-job
spec:
  template:
    metadata:
      name: math-add-job
    spec:
      restartPolicy: Never # OnFailure or Never or Always
      containers:
      - name: math-add-job-container
        image: ubuntu
        command:
         - "expr"
         - "3"
         - "+"
         - "2"

# ❗️ Create a Job imperatively
# kubectl create job math-add-job --image=ubuntu --restart=Never --command="expr 3 + 2"

# ❗️ Create a Job that runs a command in a container
# kubectl apply -f jobs/math-add-job.yml

# ❗️ To get the pod associated with the Job
# kubectl get pods -l job-name=math-add-job

# ❗️ To get output of the job
# kubectl logs -f $(kubectl get pods -l job-name=math-add-job -o jsonpath='{.items[0].metadata.name}')\
