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:
kubectl logs --selector app=kube-dns I expected to see the logs for all containers in all my kube-dns labeled pods.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.
@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
Yeap, please review https://github.com/kubernetes/kubernetes/pull/45275
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.
Most helpful comment
Yeap, please review https://github.com/kubernetes/kubernetes/pull/45275