Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does `kubectl logs` only show the most recent log rows?

I have a Kubernetes pod running on Google Container Engine. It has been running for several days, writing to the log, without any restarts.

Why is the command kubectl logs only showing log rows from today?

Where does this limitation come from and is it based on time or number of log rows?

like image 468
Niemi Avatar asked Sep 08 '16 16:09

Niemi


1 Answers

Logrotate is enabled by default on container engine VMs. You should be able to check conf at below location for docker container logs.

cat /etc/logrotate.d/docker-containers

So when you run kubectl logs, it streams you from current log file. Past logs are already gzipped and also only N compressed files are available as per logrotate configuration.

You can check all containers log files at location /var/log/containers also sym linked to /var/lib/docker/containers/$containerId/

You may also want to refer to documentation http://kubernetes.io/docs/user-guide/kubectl/kubectl_logs/ and see if additional options can come to rescue.

like image 198
Anupam Avatar answered Oct 06 '22 18:10

Anupam