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
Here is the output of kubectl get pods
Here is the log output inside the container.
Ignore the PHP exception. Issue is there regardless of the exception.
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.