<p>I want to run a Kubernetes CronJob for a PHP script. Job executes properly but status of the POD remains running and after few minutes it becomes Error. It should be Completed status. Tried with different options but couldn't be able to resolve the issue.</p>
<p><strong>Here is my CronJob Yaml file</strong></p>
<p><a href="https://i.stack.imgur.com/odNNl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/odNNl.png" alt="enter image description here" /></a></p>
<p><strong>Here is the output of kubectl get pods</strong>
<a href="https://i.stack.imgur.com/mAd71.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mAd71.png" alt="enter image description here" /></a></p>
<p><strong>Here is the log output inside the container.</strong></p>
<p>Ignore the PHP exception. Issue is there regardless of the exception.</p>
<p><a href="https://i.stack.imgur.com/BcZYj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BcZYj.png" alt="enter image description here" /></a></p>

Aruna
<p>The state of the pod sets to completed when the running process / the application or the container returns exit code <code>0</code>.</p>
<p>If in case it's returning a <strong>non-zero</strong> exit code it usually sets it to state <code>Error</code>.</p>
<p>If you want the pod set to completed status, just make sure the application at the end returning an exit code which is <code>0</code>.</p>
<p><strong>OPINION:  It's something which is usual cases should be/are handled by the application itself.</strong></p>
<p>I'm attaching <a href="https://kubernetes.io/docs/concepts/workloads/controllers/job/" rel="noreferrer">docs</a> for the k8s jobs.</p>
