apiVersion: batch/v1
kind: Job
metadata:
  name: handling-failures
spec:
  backoffLimit: 2 # Restart twice
  template:
    spec:
      containers:
      - name: job
        image: busybox
        args:
        - /bin/sh
        - -c
        - date; echo sleeping...; sleep 10; exit 1;
      restartPolicy: OnFailure # Restart job on failure