I am running a Kubernetes job, where pods are terminating and being recreated multiple times, for some unknown reason. I am assuming that the pods are terminated as a result of some sort of eviction process, as the termination occurs across all pods and all jobs simultaneously. Tailing the containers logs show no indication that the container’s command or process has failed. I am looking for a way to debug what is causing the termination of these pods.
The following is an example of the job manifest I am running:
{
"apiVersion": "batch/v1",
"kind": "Job",
"metadata": {
"generateName": "job-",
"namespace": "default"
},
"spec": {
"backoffLimit": 0,
"template": {
"spec": {
"containers": [
{
"command": [
"/bin/sh"
],
"image": "******",
"name": "x",
"resources": {
"limits": {
"cpu": 2,
"memory": "4G"
},
"requests": {
"cpu": 2,
"memory": "4G"
}
}
}
],
"restartPolicy": "Never"
}
},
"ttlSecondsAfterFinished": 600
}
}
I would like to use kubectl describe pod
and kubectl logs
to identify what caused the pods to be terminated. However, immediately upon termination, the pod is deleted and cannot be inspected using the above commands.
I have inspected kubectl get events
to try to determine the reason for the pod being terminated. However, the output gives little information:
5m16s Normal Created pod/job-q4v5l-vxtgg Created container x
5m15s Normal Started pod/job-q4v5l-vxtgg Started container x
5m15s Normal Killing pod/job-q4v5l-vxtgg Stopping container x
The kubectl describe job
command shows the following events. As can be seen from this output, a pod is repeatedly created.
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal SuccessfulCreate 6m38s job-controller Created pod: job-q4v5l-7trcd
Normal SuccessfulCreate 6m34s job-controller Created pod: job-q4v5l-zzw27
Normal SuccessfulCreate 6m33s job-controller Created pod: job-q4v5l-4crzq
Normal SuccessfulCreate 6m31s job-controller Created pod: job-q4v5l-sjbdh
Normal SuccessfulCreate 6m28s job-controller Created pod: job-q4v5l-fhz2x
Normal SuccessfulCreate 6m25s job-controller Created pod: job-q4v5l-6vgg5
Normal SuccessfulCreate 6m22s job-controller Created pod: job-q4v5l-7dmh4
Normal SuccessfulCreate 6m19s job-controller Created pod: job-q4v5l-klf4q
Normal SuccessfulCreate 6m15s job-controller Created pod: job-q4v5l-87vwx
Normal SuccessfulCreate 5m32s (x16 over 6m12s) job-controller (combined from similar events): Created pod: job-q4v5l-6x5pv