Why are my `kubectl logs` so short?

268 views
Skip to first unread message

mspr...@us.ibm.com

unread,
Jan 22, 2018, 11:53:43 AM1/22/18
to kubernetes-sig-node
When using the kubelet from Kubernetes release 1.8.4 with the default container runtime, and docker 17.03 for example, I find that `kubectl logs` shows me only a tail of what `docker logs` shows me for the same container.  In one particular example, the former shows me about 6 MB while the latter shows me about 120 MB.  What's going on here, and can I make `kubectl logs` show me as much as `docker logs`?

Thanks,
Mike

曹树烽

unread,
Feb 27, 2018, 4:34:57 AM2/27/18
to kubernetes-sig-node
`kubectl logs` is related to both kube-apiserver and kubelet.

Why not address a new issue in github?
https://github.com/kubernetes/kubernetes/issues
You will get more help there, I guess.


在 2018年1月23日星期二 UTC+8上午12:53:43,mspr...@us.ibm.com写道:

Lantao Liu

unread,
Feb 27, 2018, 2:54:48 PM2/27/18
to 曹树烽, kubernetes-sig-node
Hi mspreitz,

I think the reason is that `kubectl logs` does not support log rotation. It will only read the most recent log file.

Docker log rotation is is handled by docker itself today. Kubernetes supports multiple container runtimes (docker, cri-containerd, cri-o etc.), so we can't assume that all container logs are rotated in the docker way.

In Kubernetes 1.10, we added the alpha support of container log rotation in kubelet, it means that kubelet will be responsible for container log rotation. (See https://github.com/kubernetes/kubernetes/pull/59898)

With this we should be able to make `kubectl logs` support log rotation, because kubelet is doing logrotation, and we know exactly how the container logs are rotated, and how to read them. Here is an open source issue for this https://github.com/kubernetes/kubernetes/issues/59902

Does this make sense to you? Any help and suggestions are welcomed.

Best Regards,
Lantao

--
You received this message because you are subscribed to the Google Groups "kubernetes-sig-node" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-sig-...@googlegroups.com.
To post to this group, send email to kubernete...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kubernetes-sig-node/2d06e4d9-86c6-4e80-8494-3e835d82d195%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages