kubectl logs command with label selector does not show all entries (results truncated)

Created on 19 Aug 2020  路  3Comments  路  Source: kubernetes/kubectl

What happened:

Executed command:

kubectl logs -n kube-system -l k8s-app=kube-dns

Only received a subset of the logs from the pods with the label.
Manually collecting the logs pod-by-pod shows many more results. It's as if using the label selector causes the results to be truncated.
Seems to only return 20 lines max.

What you expected to happen:

Expected to see all results for all log entries of all pods.

How to reproduce it (as minimally and precisely as possible):

  1. Execute command: kubectl logs -n kube-system -l k8s-app=kube-dns
  2. Compare with results of kubectl logs -n kube-system <dnsPodName>

Anything else we need to know?:

N/A

Environment:

  • Kubernetes client and server versions (use kubectl version):

kubectl version --short
Client Version: v1.18.2
Server Version: v1.17.7

  • Cloud provider or hardware configuration: Azure Kubernetes Service (AKS)
  • OS (e.g: cat /etc/os-release):

NAME="Ubuntu"
VERSION="20.04 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal

kinbug

Most helpful comment

Thank you @zhouya0 , makes sense - as expected this behaves properly for me with:

kubectl logs -n kube-system -l k8s-app=kube-dns --tail -1

Thanks for your help and the clarification!

All 3 comments

/assign

See help info in kubectl logs --help:

cmd.Flags().Int64Var(&o.Tail, "tail", o.Tail, "Lines of recent log file to display. Defaults to -1 with no selector, showing all log lines otherwise 10, if a selector is provided.")

Thank you @zhouya0 , makes sense - as expected this behaves properly for me with:

kubectl logs -n kube-system -l k8s-app=kube-dns --tail -1

Thanks for your help and the clarification!

Was this page helpful?
0 / 5 - 0 ratings