<p>I am running selenium hubs and my pods are getting terminated frequently. I would like to look at the logs of the pods which are terminated. How to do it?</p>
<pre><code>NAME                                               READY     STATUS              RESTARTS   AGE
chrome-75-0-0e5d3b3d-3580-49d1-bc25-3296fdb52666   0/2       Terminating         0          49s
chrome-75-0-29bea6df-1b1a-458c-ad10-701fe44bb478   0/2       Terminating         0          23s
chrome-75-0-8929d8c8-1f7b-4eba-96f2-918f7a0d77f5   0/2       ContainerCreating   0          7s

kubectl logs chrome-75-0-8929d8c8-1f7b-4eba-96f2-918f7a0d77f5
Error from server (NotFound): pods &quot;chrome-75-0-8929d8c8-1f7b-4eba-96f2-918f7a0d77f5&quot; not found
$ kubectl logs chrome-75-0-8929d8c8-1f7b-4eba-96f2-918f7a0d77f5 --previous
Error from server (NotFound): pods &quot;chrome-75-0-8929d8c8-1f7b-4eba-96f2-918f7a0d77f5&quot; not found
</code></pre>

SunilS
<p>Running <code>kubectl logs -p</code> will fetch logs from existing resources at API level. This means that terminated pods' logs will be unavailable using this command.</p>

<p>As mentioned in other answers, the best way is to have your logs centralized via <a href="https://kubernetes.io/docs/concepts/cluster-administration/logging/#cluster-level-logging-architectures" rel="noreferrer">logging agents or directly pushing these logs into an external service</a>.</p>

<p>Alternatively and given the <a href="https://kubernetes.io/docs/concepts/cluster-administration/logging/#logging-at-the-node-level" rel="noreferrer">logging architecture in Kubernetes</a>, you might be able to <a href="https://kubernetes.io/docs/concepts/cluster-administration/logging/#system-component-logs" rel="noreferrer">fetch the logs directly from the log-rotate files</a> in the node hosting the pods. However, this option might depend on the Kubernetes implementation as log files might be deleted when the pod eviction is triggered.</p>
