Kubernetes Job: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 4: Line 4:
=Internal=
=Internal=
* [[Kubernetes Workload Resources#Job|Kubernetes Workload Resources]]
* [[Kubernetes Workload Resources#Job|Kubernetes Workload Resources]]
* [[Kubernetes_CronJob|CronJob]]
* [[Kubernetes API Resources Concepts#Job|API Resources]]
* [[Kubernetes API Resources Concepts#Job|API Resources]]



Revision as of 21:13, 14 July 2023

External

Internal

Overview

A Kubernetes Job is a workload resource that can be used to start and manage Pods to successful completion.

A Pod is considered completed, and thus its execution counted against the completion counter only if finishes successfully. This counter can be configured with .spec.completions. When the specified number of successful completions is reached, the Job is complete. The Job will attempt to restart failed Pods, which don't count against successful executions. The number of retires until the attempts are dropped can be configured with .spec.backoffLimit. More details on a Job's life cycle is available in the Job Lifecycle section.

Pods can be executed in parallel. The Parallel Execution section provides more details on that.

If the Job needs to execute on a schedule, a CronJob is a better tool.

Kubernetes Job Manifest

Job Manifest

Job Lifecycle

Parallel Execution

Clean up Finished Jobs Automatically

https://kubernetes.io/docs/concepts/workloads/controllers/job/#clean-up-finished-jobs-automatically

Jobs that have finished, either "Complete" or "Failed" can be automatically be deleted by using the TTL mechanism provided by the [TTL Controller ]. Set the .spec.ttlSecondsAfterFinished field in the job manifest. If the field is set to 0, the Job will be eligible to be automatically deleted immediately after it finishes.

apiVersion: batch/v1
kind: Job
spec:
  ttlSecondsAfterFinished: 100
  ...