Commit Graph

13 Commits

Author SHA1 Message Date
Case Wylie b1dfef4f42 feat: add all-pods log flag to kubectl
Signed-off-by: Case Wylie <cmwylie19@defenseunicorns.com>

Kubernetes-commit: 6db859eb5de14d748ace74974951697477848ee9
2024-05-07 19:43:46 -04:00
Paco Xu 266e17f8a6 remove deprecated kubectl.kubernetes.io/default-logs-container support
Kubernetes-commit: 3a9c6f2a2f59cb05fc505f66afe2bd923a0d9f58
2022-04-02 16:40:34 +08:00
Jian Li 3f7abd9859 cmd/kubectl: make 'kubectl logs' default to the first container when default container cannot be determined or found by annotations (#105964)
* cmd/kubectl: make 'kubectl logs' default to the first container.

While running 'kubectl logs <pod>', If '-c' is omited and the pod has more than one container, and no default container can be determined from annotations, this command shows an error message and exits. With this fix, it defaults to the first container in such scenarios and show its logs. This aligns behavior with what 'kubectl exec' does currently, and is more in line with KEP SIG-CLI 2227 design.

* fix unit test(forgotten)

* fix spelling typo

Kubernetes-commit: 0977a5d7cda59d5bd324bf2730846905e072fbbf
2022-01-07 09:40:41 +08:00
Kebe 316e6d8845 Fix the code is leaking the defaulting between unrelated pod instances
Kubernetes-commit: 412962204ffdfcbe6407e66125b1b499d86d49ed
2021-07-09 09:57:05 +08:00
Clayton Coleman 56434236a4 kubectl: Inline the containers for the user in attach/exec
The behavior of the container defaulting in attach/exec is inconsistent
and should be unified. As a user, when we default the vast majority of
pods will have a small number of containers and so printing the container
names inline (as kubectl logs did) is more appropriate. The debug message
we printed about using describe was already longer than 99% of all pod
container names, so we were wasting user time.

Unify container selection for exec and attach to be consistent with old
behavior. Properly handle the --quiet flag (should not print in that case)
for both commands. Remove EnableCmdSuggestion and the machinery it needs.

The message now prints:

> Defaulted container "etcdctl" out of: etcdctl, etcd, etcd-metrics, etcd-ensure-env-vars (init), etcd-resources-copy (init)

Kubernetes-commit: 43e8ebbbcd3f57d18d8151efb6242f88a763b06d
2021-02-11 11:40:25 -05:00
John Howard c8325cdd3b Improve warnings for default-container
Right now, there is no way to use these annotations, support multiple
`kubectl` versions, and not give users annoying warnings every time they
run `kubectl log`.

If a user is setting *both* annotations, they clearly know that the old
on is deprecated. Therefor, we should not warn them.

Kubernetes-commit: a7882d8a4264cdb9eaab9dc3d67cf0cc5afd5886
2021-03-02 09:07:50 -08:00
pacoxu aedad91395 fix: will logs the default container only even --all-containers is specified
Signed-off-by: pacoxu <paco.xu@daocloud.io>

Kubernetes-commit: 71db08d15a580cee1592eb699a3ff448f5fe4fe1
2021-03-01 11:00:05 +08:00
pacoxu 8d367eb060 move default container annotation to kubectl pkg
Kubernetes-commit: 27bd94e54d2f8a7676411b280ab9d0ac7f9e921b
2021-02-26 10:11:12 +08:00
pacoxu 360e8d2b15 feature: use default container annotation for logs and exec
- update according to KEP: move getContainerName to helper

Signed-off-by: pacoxu <paco.xu@daocloud.io>

Kubernetes-commit: b54e823dbce08bff6fab979243663b0fea5a351f
2020-12-07 15:30:30 +08:00
Michal Fojtik cbb6f76ae7 kubectl: allow to preselect interesting container in logs
Kubernetes-commit: 439f93c91b81eee29f2aa5c4cf6fff911e26e684
2020-02-04 13:14:43 +01:00
Mikalai Radchuk a38258b351 Adds --prefix flag to the kubectl log command
Kubernetes-commit: 8cadd185d67e84dd186728669d6e72e9e415db70
2019-09-04 16:23:02 +01:00
Lee Verberne c5bce989ce Update kubectl polymorphic logs helper for ephemeral containers
This also updates the test to check there were actual actions that
weren't expected.

Kubernetes-commit: 66d077882854bc407f27a4ecd47deb157fe7a47d
2019-08-27 09:35:16 +00:00
Sean Sullivan f266a308e1 Move pkg/kubectl/polymorphichelpers staging
Kubernetes-commit: 9f3384f02f472b0095fe3675139c08e7aaa7e711
2019-07-27 19:48:15 -07:00