Kubernetes CronJob Pod status remains Running

1/1/2021

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.

Here is my CronJob Yaml file

enter image description here

Here is the output of kubectl get pods enter image description here

Here is the log output inside the container.

Ignore the PHP exception. Issue is there regardless of the exception.

enter image description here

-- Aruna
docker
kubectl
kubernetes
kubernetes-cronjob

1 Answer

1/4/2021

The state of the pod sets to completed when the running process / the application or the container returns exit code 0.

If in case it's returning a non-zero exit code it usually sets it to state Error.

If you want the pod set to completed status, just make sure the application at the end returning an exit code which is 0.

OPINION: It's something which is usual cases should be/are handled by the application itself.

I'm attaching docs for the k8s jobs.

-- Saikat Chakrabortty
Source: StackOverflow