Kubernetes log - from the beginning

6/15/2018

I have been running a pod for more than a week and there has been no restart since started. But, still I am unable to view the logs since it started and it only gives logs for the last two days. Is there any log rotation policy for the container and how to control the rotation like based on size or date?

I tried the below command but shows only last two days logs.

kubectl logs POD_NAME --since=0

Is there any other way?

-- user1578872
kubernetes

1 Answer

6/15/2018

Is there any log rotation policy for the container and how to control the rotation like based on size or date

The log rotation is controlled by the docker --log-driver and --log-opts (or their daemon.json equivalent), which for any sane system has file size and file count limits to prevent a run-away service from blowing out the disk on the docker host. that answer also assumes you are using docker, but that's a fairly safe assumption

Is there any other way?

I strongly advise something like fluentd-elasticsearch, or graylog2, or Sumologic, or Splunk, or whatever in order to egress those logs from the hosts. No serious cluster would rely on infinite log disks nor on using kubectl logs in a for loop to search the output of Pods. To say nothing of egressing the logs from the kubernetes containers themselves, which is almost essential for keeping tabs on the health of the cluster.

-- mdaniel
Source: StackOverflow