Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubectl logs command doesn't show logs from all the pods when using label selector #1713

Open
blessedwithsins opened this issue Feb 10, 2025 · 4 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@blessedwithsins
Copy link

What happened: I'm using kubectl logs command to get the logs of multiple pods of same application using labels. However, it doesn't give logs from all the pods.

What you expected to happen: I should be able to use the -f/--follow option to get the logs from all the pods and use grep/awk with it.

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

Running multiple replicas of a deployment, try to get the logs using label selector.

Anything else we need to know?: NA

Environment:

  • Kubernetes client and server versions (use kubectl version): v1.29.0
  • Cloud provider or hardware configuration: GCP
  • OS (e.g: cat /etc/os-release):
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 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
UBUNTU_CODENAME=focal
@blessedwithsins blessedwithsins added the kind/bug Categorizes issue or PR as related to a bug. label Feb 10, 2025
@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Feb 10, 2025
@ardaguclu
Copy link
Member

@blessedwithsins
Copy link
Author

Are you saying that this usage pattern https://github.com/kubernetes/kubernetes/blob/9e555875e79f60a238952e91e91f79f32c053f9c/staging/src/k8s.io/kubectl/pkg/cmd/logs/logs.go#L77 does not work?

This one works. Is it mandatory to use --all-containers=true to fetch the logs? IMHO it should work without that as well if I'm using label selector.

@sftim
Copy link
Contributor

sftim commented Feb 18, 2025

Maybe you meant kubectl logs deployment/examplename --all-pods=true --follow? --all-containers has a different effect.

@sftim
Copy link
Contributor

sftim commented Feb 18, 2025

/triage needs-information

@k8s-ci-robot k8s-ci-robot added triage/needs-information Indicates an issue needs more information in order to work on it. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Feb 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests

4 participants