<p>I am running Kubernetes jobs via cron. In some cases the jobs may fail and I want them to restart. I'm scheduling the jobs like this:</p>

<p><code>kubectl run collector-60053 --schedule=30 10 * * * * --image=gcr.io/myimage/collector --restart=OnFailure --command node collector.js</code></p>

<p>I'm having a problem where some of these jobs are running and failing but the associated pods are disappearing, so I have no way to look at the logs and they are not restarting.</p>

<p>For example:</p>

<pre><code>$ kubectl get jobs | grep 60053
collector-60053-1546943400     1         0            1h
$ kubectl get pods -a | grep 60053
$    // nothing returned
</code></pre>

<p>This is on Google Cloud Platform running 1.10.9-gke.5</p>

<p>Any help would be much appreciated!</p>

<p>EDIT:</p>

<p>I discovered some more information. I have auto-scaling setup on my GCP cluster. I noticed that when the servers are removed the pods are also removed (and their meta data). Is that expected behavior? Unfortunately this gives me no easy way to look at the pod logs.</p>

<p>My theory is that as pods fail, the CrashLoopBackOff kicks in and eventually auto-scaling decides that the node is no longer needed (it doesn't see the pod as an active workload). At this point, the node goes away and so do the pods. I don't think this is expected behavior with Restart OnFailure but I basically witnessed this by watching it closely.</p>

user1527312
<p>After digging much further into this issue, I have an understating of my situation. According to <a href="https://github.com/kubernetes/kubernetes/issues/54870" rel="nofollow noreferrer">issue 54870</a> on the Kubernetes repository, there are some problems with jobs when set to <code>Restart=OnFailure</code>.</p>
<p>I have changed my configuration to use <code>Restart=Never</code> and to set a <code>backoffLimit</code> for the job. Even though restart is set to never, in my testing with restart never, Kubernetes will actually restart the pods up to the <code>backoffLimit</code> setting and keep the error pods around for inspection.</p>
