#
#  Author: Hari Sekhon
#  Date: [% DATE  # 2019-11-28 18:51:59 +0000 (Thu, 28 Nov 2019) %]
#
#  vim:ts=2:sts=2:sw=2:et
#
#  https://github.com/harisekhon/Kubernetes-configs
#
#  License: see accompanying Hari Sekhon LICENSE file
#
#  If you're using my code you're welcome to connect with me on LinkedIn
#  and optionally send me feedback to help improve or steer this or other code I publish
#
#  https://www.linkedin.com/in/HariSekhon
#

# ============================================================================ #
#                                     J o b
# ============================================================================ #

# https://kubernetes.io/docs/concepts/workloads/controllers/job/

---
apiVersion: batch/v1
kind: Job
metadata:
  name: NAME
  namespace: NAMESPACE
spec:
  completions: 8  # total successful jobs - omit this for queue pattern where any pod successfully finishes
  parallelism: 4  # concurrent jobs
  template:
    metadata:
      name: NAME
    spec:
      containers:
        - name: NAME
          image: perl
          # takes about a minute to execute
          command:
            - perl
          args:
            - -Mbignum=bpi
            - -wle
            - print bpi(2000)
      restartPolicy: Never
  # exponential backoff retries of job - 10 => 20 => 40 secs...
  backoffLimit: 6  # default, max job retries
  activeDeadlineSeconds: 300  # max job runtime
