<p>we are doing case study with control-m to monitor Kubernetes job.
On successful completions of job, control -m is able to recognize the job completed.
however when it fails, it never recognize the failure it shows job is still running,i suspect job never gets completed in kubernetes.</p>
<p>Here as job, pod status and kubernetes yaml file.</p>
<p>My question, is there way to kubernetes job complete with failure?
or is it default behavior of kubernetes?</p>
<pre><code>#  kubectl -n ns-dev get job
NAME                             COMPLETIONS   DURATION   AGE
job-pod-failure-policy-example   0/1           3m39s      3m39s
# kubectl -n ns-dev get pods
NAME                                   READY   STATUS      RESTARTS   AGE
job-pod-failure-policy-example-h86bp  0/1     Error       0          82s
Yaml file:
apiVersion: batch/v1
kind: Job
metadata:
  name: job-pod-failure-policy-example
spec:
  template:
    spec:
      restartPolicy: Never
      containers:
      - name: main
        image: docker.io/library/bash:5
        command: [&quot;bash&quot;]        # example command simulating a bug which triggers the FailJob action
        args:
        - -c
        - echo &quot;Hello world!&quot; &amp;&amp; sleep 5 &amp;&amp; exit 1
  backoffLimit: 0
  podFailurePolicy:
    rules:
    - action: Terminate
      onExitCodes:
        containerName: main
        operator: In
        values: [1]
</code></pre>
<p>I have gone through below link to help to set the backoff limit to zero  which helped stop retriggering multiple times.</p>
<p><strong><a href="https://stackoverflow.com/questions/62443173/kubernetes-job-keeps-spinning-up-pods-which-end-up-with-the-error-status">Kubernetes job keeps spinning up pods which end up with the &#39;Error&#39; status</a></strong></p>

Programmer007
<blockquote>
<p>My question, is there way to kubernetes job complete with failure? or
is it default behavior of kubernetes?</p>
</blockquote>
<p>You can manage it from the code mostly, if there is any error gracefully shutdown or pass the proper exit code.</p>
<p><strong>Kubernetes</strong> have two status only <strong>Failed</strong> or <strong>Complete</strong>.</p>
<p>But you can update the and mark the job as complete also by hitting the api-server with path request</p>
<pre><code>curl &lt;Api server&gt;/apis/batch/v1/namespaces/&lt;namespacename&gt;/jobs/&lt;job name&gt;/status -XPATCH  -H &quot;Accept: application/json&quot; -H &quot;Content-Type: application/strategic-merge-patch+json&quot; -d '{&quot;status&quot;: {&quot;succeeded&quot;: 1}}'
</code></pre>
