<p>I'm running a K8S job, with the following flags:</p>
<pre><code>apiVersion: batch/v1
kind: Job
metadata:
  name: my-EP
spec:
  template:
    metadata:
      labels:
        app: EP
    spec:
      restartPolicy: &quot;Never&quot;
      containers:
      - name: EP
        image: myImage
</code></pre>
<p>The Job starts, runs my script that runs some application that sends me an email and then terminates. The application returns the exit code to the bash script.
when I run the command:
kubectl get pods, I get the following:</p>
<pre><code>NAME               READY   STATUS      RESTARTS   AGE
my-EP-94rh8   0/1     Completed   0          2m2s
</code></pre>
<p>Sometimes there are issues, and the network not connected or no license available.
I would like that to be visible to the pod user.
My question is, can I propagate the script exit code to be seen when I run the above get pods command?
I.E instead of the &quot;Completed&quot; status, I would like to see my application exit code - 0, 1, 2, 3....
or maybe there is a way to see it in the Pods Statuses, in the describe command?
currently I see:</p>
<pre><code>Pods Statuses:  0 Running / 1 Succeeded / 0 Failed
</code></pre>
<p>Is this possible?</p>

Mary1
<p>The a non-zero exit code on <a href="https://kubernetes.io/docs/concepts/workloads/controllers/job/" rel="nofollow noreferrer">k8s jobs</a> will fall into the <code>Failed</code> pod status. There really isn't a way for you to have the exit code shown with <code>kubectl get pods</code> but you could output the pod status with <code>-ojson</code> and then pipe it into <code>jq</code> looking for the exit code. Something like the following from <a href="https://stackoverflow.com/a/61341173/703161">this post</a> might work</p>
<pre><code> kubectl get pod pod_name -c container_name-n namespace -ojson | jq .status.containerStatuses[].state.terminated.exitCode
</code></pre>
<p>or this, with the <code>items[]</code> in the json</p>
<pre><code>kubectl get pods -ojson | jq .items[].status.containerStatuses[].state.terminated.exitCode
</code></pre>
<p>Alternatively, as <code>u/blaimi</code> mentioned, you can do it without <code>jq</code>, like this:</p>
<pre><code>kubectl get pod pod_name -o jsonpath --template='{.status.containerStatuses[*].state.terminated.exitCode}
</code></pre>
