What is the difference between a Pod and a Job resources in k8s?

1/12/2020

Is Pod and Job resource the same ?

apiVersion: v1
kind: Pod
metadata:
  name: ""
  labels:

or

apiVersion: v1
kind: Job
metadata:
  name: ""
  labels:

The Job will still create a pod I think. Just wondering when do I use one instead of the other.

-- alltej
kubernetes
kubernetes-helm
kubernetes-ingress

2 Answers

1/12/2020

Pod is basic unit to express a runnable process on Kubernetes.

Job is a higher level abstraction that uses pods to run a completable task.

You might be thinking of using a pod with restartPolicy: Never to run a completable task. But in the event of node failure, pod on that node managed by Job are rescheduled to other node but an unmanaged pod is not.

Job also has extra features like completions and parallelism using which you can run multiple instances.

-- Shashank V
Source: StackOverflow

1/12/2020

Use Jobs if your tasks will complete (e.g. computes π to 2000 places and prints it out).

Under the hood, Job uses Pods for the computation. Imagine Job is a higher level of abstraction than Pods.

https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/

-- Tang
Source: StackOverflow