Kubernetes Job Manifest: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
=External=
=External=
* https://kubernetes.io/docs/concepts/workloads/controllers/job/#writing-a-job-spec
* https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/job-v1/
* https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/job-v1/


=Internal=
=Internal=
* [[Kubernetes_Job#Kubernetes_Job_Manifest|Kubernetes Job]]
* [[Kubernetes_Job#Kubernetes_Job_Manifest|Kubernetes Job]]
=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 counted against the completion counter only if finishes successfully. The job can be configured to manage a specific number of successful executions with <code>[[Kubernetes_Job_Manifest#completions|.spec.completions]]</code>.
=Example=
=Example=


Line 20: Line 17:
   template:
   template:
     spec:
     spec:
      restartPolicy: Never
       containers:
       containers:
       - name: test-container
       - name: test-container
         image: docker.com/some-image:1.0.0
         image: docker.com/some-image:1.0.0
         command: ["some-command", "test"]
         command: ["some-command", "test"]
      restartPolicy: Never
</font>
</font>


Line 32: Line 29:
==<tt>backoffLimit</tt>==
==<tt>backoffLimit</tt>==
Specifies the number of retries before marking this job failed. Defaults to 6. Retries are counted in addition to the initial execution.
Specifies the number of retries before marking this job failed. Defaults to 6. Retries are counted in addition to the initial execution.
==The Pod <tt>template</tt>==
===<tt>restartPolicy</tt>===
Only a <code>RestartPolicy</code> equal to <code>Never<code> or <code>OnFailure</code> is allowed.

Latest revision as of 21:22, 14 July 2023

External

Internal

Example

apiVersion: batch/v1
kind: Job
metadata:
  name: test-job
spec:
  completions: 1
  backoffLimit: 0
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: test-container
        image: docker.com/some-image:1.0.0
        command: ["some-command", "test"]

.metadata Elements

.spec Elements

completions

backoffLimit

Specifies the number of retries before marking this job failed. Defaults to 6. Retries are counted in addition to the initial execution.

The Pod template

restartPolicy

Only a RestartPolicy equal to Never or OnFailure is allowed.