Commit Graph

24 Commits

Author SHA1 Message Date
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
Maciej Szulik 69bc307556 Fix batch/v1 CronJob support in create, describe and polymorphichelpers
Kubernetes-commit: a68582d6086ffc8608779b0459de8d387042eed1
2021-03-09 09:44:02 +01: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
Maciej Szulik 6b4e2b9b05 Drop batch/v2alpha1 API
Kubernetes-commit: 3dab7462d1ff6e20f7efe38249dd9958e4e32c89
2020-12-01 16:33:47 +01:00
Dinesh b17989102f Add tests for daemonset view history
Signed-off-by: Dinesh <dineshudt17@gmail.com>

Kubernetes-commit: c88b5e2ef36b4d026ec5852beff404197c199797
2020-09-05 22:10:28 +05:30
Dinesh 55c16b433f Add commend for printHistory function
Signed-off-by: Dinesh <dineshudt17@gmail.com>

Kubernetes-commit: 548b3a784bf2d05a8cfbaf289ce257d7b71efab2
2020-09-05 21:43:22 +05:30
Dinesh 88b59619ba dedup the printHistory logic in DaemonSetHistoryViewer,StatefulSetHistoryViewer
Signed-off-by: Dinesh <dineshudt17@gmail.com>

Kubernetes-commit: fe1e72e792c0f9f42e0ba2e3291ed0dde2cf262a
2020-03-29 21:12:49 +05:30
Dinesh e112514f70 Describe sts on rollout history if the revision
Signed-off-by: Dinesh <dineshudt17@gmail.com>

Kubernetes-commit: 2749dbdc9a1f1e6947278e70daed966749d80426
2019-12-21 15:16:50 +05:30
Maciej Szulik e034e09126 Squash pkg/describe/versioned/ into pkg/describe/
Kubernetes-commit: 02cd65d7bb5e4aea84a4f466186bcbbe604c4b27
2020-03-03 13:06:26 +01:00
Julian V. Modesto f9460c5333 Use --dry-run=client,server in kubectl.
- Support --dry-run=server for subcommands apply, run, create, annotate,
expose, patch, label, autoscale, apply set-last-applied, drain, rollout undo
- Support --dry-run=server for set subcommands
  - image
  - resources
  - serviceaccount
  - selector
  - env
  - subject
- Support --dry-run=server for create subcommands.
  - clusterrole
  - clusterrolebinding
  - configmap
  - cronjob
  - job
  - deployment
  - namespace
  - poddisruptionbudget
  - priorityclass
  - quota
  - role
  - rolebinding
  - service
  - secret
  - serviceaccount
- Remove GetClientSideDryRun

Kubernetes-commit: 13b80b48cd02b8263d910f2423a1f5b92cdf7644
2020-01-30 20:23:33 -05:00
Mike Danese 29cd24b6cc generated: run refactor
Kubernetes-commit: 25651408aeadf38c3df7ea8c760e7519fd37d625
2020-02-08 12:30:21 -05:00
Mike Danese 71d8052cb0 generated: run refactor
Kubernetes-commit: 3aa59f7f3077642592dc8a864fcef8ba98699894
2020-02-07 18:16:47 -08:00
Michal Fojtik cbb6f76ae7 kubectl: allow to preselect interesting container in logs
Kubernetes-commit: 439f93c91b81eee29f2aa5c4cf6fff911e26e684
2020-02-04 13:14:43 +01:00
whalecold 18810c4eb5 Fix(kubectl): the field of history controllerrevision will be covered by daemonset
Kubernetes-commit: 5b2cc9c2fd69d766e05c2cf476e9a9a344005155
2019-12-12 23:14:47 +08:00
Wojciech Tyczynski 24d21a0ee4 Fix kubectl conversions
Kubernetes-commit: bfa4188123ed334d4f5dda3a79994cadf663d8f2
2019-11-17 18:35:55 +01:00
Mikalai Radchuk a38258b351 Adds --prefix flag to the kubectl log command
Kubernetes-commit: 8cadd185d67e84dd186728669d6e72e9e415db70
2019-09-04 16:23:02 +01:00
ZP-AlwaysWin da06ecc74b Fix bug The statefulset have duplicate revision after resource was updated
Kubernetes-commit: e081d1dca65e738a2541023968251e58b9abf656
2019-09-12 22:26:09 +08: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