4

I have pods running in OpenShift that I would like to view the logs for. In particular, I want to see the logs when the pod is terminated.

However, when the pod is terminated the logs are deleted as far as I can tell. I've tried tailing 'oc logs ' but I lose the output once the pod is gone.

What is a clean way to copy these logs in real time or print them to stdout so that they will persist after the pod is killed?

Ortomala Lokni
  • 4,665
  • 3
  • 31
  • 58
  • If I understood correctly the I assume you are running docker commands with `docker run --rm` (`--rm` this deletes the container). Maybe while the container is running you can use something like: `docker logs --details --follow id_container > /tmp/id_container.logs` – Edgar Magallon Feb 10 '23 at 05:36

1 Answers1

2

The simplest solution is to associate a persistent volume to the pod and to redirect the log file to this volume.

Another way is to use a log collector such as fluentd and the ELK stack to index and visualize them.

You can also use the cluster-level OpenShift logging infrastructure.

Ortomala Lokni
  • 4,665
  • 3
  • 31
  • 58