<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: echo-job
spec:
  template:
    metadata:
      name: echo
    spec:
      containers:
      - name: echo
        image: busybox
        command: ['echo', 'Hello Kubernetes Jobs!']
      restartPolicy: Never
  backoffLimit: 4
</code></pre>
<p>Can someone please explain to me what is the difference between the following two fields:
<code>metadata: name: echo-job</code>
and
<code>spec: template: metadata: name: echo</code></p>
<p>What do these two different values represent?</p>

james gem
<p><code>metadata.name</code> is the name <strong>of the job</strong>.</p>
<p><code>spec.template.metadata.name</code> is the name <strong>of the pod created by the job</strong> (which will also have a random suffix appended).</p>
<p>If I submit your manifest, we see the Job:</p>
<pre><code>$ kubectl get job
NAME       COMPLETIONS   DURATION   AGE
echo-job   1/1           4s         14s
</code></pre>
<p>And we see the Pod created to run the Job:</p>
<pre><code>$ kubectl get pod
NAME             READY   STATUS      RESTARTS   AGE
echo-job-q9jxq   0/1     Completed   0          51s
</code></pre>
<hr />
<p>A single Job may end up creating multiple Pods if the Job fails. For example, if we replace your <code>echo</code> command with <code>[&quot;sh&quot;, &quot;-c&quot;, &quot;exit 1&quot;]</code>, we might see:</p>
<pre><code>NAME             READY   STATUS   RESTARTS   AGE
echo-job-2n9qt   0/1     Error    0          2s
echo-job-hw5wj   0/1     Error    0          22s
echo-job-n44ql   0/1     Error    0          33s
</code></pre>
