I see that Kubernetes Job
& Deployment
provide very similar configuration. Both can deploy one or more pods with certain configuration. So I have few queries around these:
.spec.template
different in Job
& Deployment
?Job
's completions
& Deployment
's replicas
?Deployment
's only container and it completes (no server or daemon process containers), the pod would terminate. The same is applicable in a Job
as well. So how is the pod lifecycle different in either of the resources?Many resources in Kubernetes use a Pod template. Both Deployments
and Jobs
use it, because they manage Pods.
Controllers for workload resources create Pods from a pod template and manage those Pods on your behalf.
PodTemplates are specifications for creating Pods, and are included in workload resources such as Deployments, Jobs, and DaemonSets.
The main difference between Deployments
and Jobs
is how they handle a Pod that is terminated. A Deployment is intended to be a "service", e.g. it should be up-and-running, so it will try to restart the Pods it manage, to match the desired number of replicas. While a Job is intended to execute and successfully terminate.