Kubectl: Cannot fetch multi-container pod logs by selector

Created on 22 Jun 2017  路  6Comments  路  Source: kubernetes/kubectl

kubectl version:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.1", GitCommit:"b0b7a323cc5a4a2019b2e9520c21c7830b7f708e", GitTreeState:"clean", BuildDate:"2017-04-03T20:44:38Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.1", GitCommit:"b0b7a323cc5a4a2019b2e9520c21c7830b7f708e", GitTreeState:"clean", BuildDate:"2017-04-03T20:33:27Z", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}

What happened:

When attempting to fetch the logs of a pod using a selector kubectl seems to demand a container name, but then does not allow a container name to be passed.

$ kubectl logs --selector app=kube-dns
Error from server (BadRequest): a container name must be specified for pod kube-dns-2325730542-99bh1, choose one of: [kubedns dnsmasq dnsmasq-metrics healthz]
$ kubectl logs --selector app=kube-dns --container  kubedns
error: a container cannot be specified when using a selector (-l)

What you expected to happen:

  1. With kubectl logs --selector app=kube-dns I expected to see the logs for all containers in all my kube-dns labeled pods.
  2. With kubectl logs --selector app=kube-dns --container kubedns I expected to see the logs for all the kubedns containers in all my pod kube-dns labeled pods.

Also acceptable would be if one of those two commands failed with one of the above errors, but then the other command worked.

How to reproduce it:

Attempt to get logs for a multi-pod container using a selector.

Most helpful comment

All 6 comments

@shiywang IIRC you implement this feature, can you look into this?

@mengqiy sure

FYI https://github.com/kubernetes/kubernetes/pull/45275, I think @CaoShuFeng is working on this

For anyone else looking at this issue, it seems https://github.com/kubernetes/kubernetes/pull/44282 will resolve this, and https://github.com/kubernetes/kubernetes/pull/45275 will also be really helpful. Given that https://github.com/kubernetes/kubernetes/pull/44282 has been merged, I'm going to close this issue.

@mnussbaum Since PR https://github.com/kubernetes/kubernetes/pull/45275 was abandoned by its author, I created https://github.com/kubernetes/kubectl/issues/371 to track it separately.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alkar picture alkar  路  6Comments

ZhilinS picture ZhilinS  路  5Comments

whs-dot-hk picture whs-dot-hk  路  6Comments

fiksn picture fiksn  路  3Comments

pwittrock picture pwittrock  路  6Comments