Commit Graph

56 Commits

Author SHA1 Message Date
Arda Güçlü 484ede079f KEP-4292: Add e2e test for custom profile in kubectl debug (#127187)
* Remove KUBECTL_DEBUG_CUSTOM_PROFILE env var

* Add e2e test for custom profile in kubectl debug

* Keep feature flag until 1.33

* Update comment

* Simplify tests by relying on test framework functionality

* Rename import alias to better to pass verify-import-alias

Kubernetes-commit: 1caf9a150b794a7c4a17e63a54b902ec0b0be570
2024-10-22 21:48:59 +03:00
Maciej Szulik 80dc149179 Fix spacing in --validate flag description
Kubernetes-commit: 7b0660ec9f572c7b8c964c5447aa9169684f9a2b
2024-10-15 11:16:33 +02:00
Abhishek Kr Srivastav 36d480f43c Fix Go vet errors for master golang
Co-authored-by: Rajalakshmi-Girish <rajalakshmi.girish1@ibm.com>
Co-authored-by: Abhishek Kr Srivastav <Abhishek.kr.srivastav@ibm.com>

Kubernetes-commit: 95860cff1c418ea6f5494e4a6168e7acd1c390ec
2024-09-12 18:15:22 +05:30
Stephen Kitt 713b7e79c0 Use canonical json-patch v4 import
The canonical import for json-patch v4 is
gopkg.in/evanphx/json-patch.v4 (see
https://github.com/evanphx/json-patch/blob/master/README.md#get-it for
reference).

Using the v4-specific path should also reduce the risk of unwanted v5
upgrade attempts, because they won't be offered as automated upgrades
by dependency upgrade management tools, and they won't happen through
indirect dependencies (see
https://github.com/kubernetes/kubernetes/pull/120327 for context).

Signed-off-by: Stephen Kitt <skitt@redhat.com>

Kubernetes-commit: 5300466a5c8988b479a151ceb77f49dd00065c83
2024-02-16 13:57:24 +01:00
Arda Güçlü 49f3ec973c Add e2e test for kubectl interactive delete
Kubernetes-commit: 7faa8bbac3bbd36a4ee680e6f82460d587186139
2024-01-09 10:12:42 +03:00
Arda Güçlü 14d23cc879 Add custom debug profiles on top of static profiles
This PR adds `custom` flag to let user customizes debug resources.
`custom` flag accepts partial container spec in json format.

Kubernetes-commit: af2dadcb18a0411a0f9aa286c743801efdb81049
2023-09-01 11:46:01 +03:00
Sean Sullivan 858d3a5b72 portforward: tunnel spdy through websockets
Kubernetes-commit: 8b447d8c97e8823b4308eb91cf7d75693e867c61
2024-02-21 08:56:07 +00:00
yulng 4afdc439d1 remove PruneWhitelist, use prune-allowlist instead
Signed-off-by: yulng <wei.yang@daocloud.io>
Signed-off-by: Paco Xu <paco.xu@daocloud.io>

Kubernetes-commit: 06679402e75d001d54770c9ec67cacbf28794009
2023-07-05 11:38:20 +08:00
Jefftree 351ba8bb1c Lazy load OpenAPIV2
Kubernetes-commit: eb32969ab8f3d1455c33a595bba5b3ce4d8a03b8
2023-10-30 15:42:22 -04:00
Jefftree 8c8a04f6d0 Add feature toggle for OpenAPI V3 apply in kubectl
Kubernetes-commit: f23ab829bee7951188d3196c16794cc489d0348c
2023-10-27 01:23:19 -04:00
Sean Sullivan 969a47ceed StreamTranslator and FallbackExecutor for WebSockets
Kubernetes-commit: 168998e87bfd49a1b0bc6402761fafd5ace3bb3b
2023-07-06 21:22:07 -07:00
Maciej Szulik bdf68c0441 Allow using upper and lower case true|false when setting kubectl feature flags
Kubernetes-commit: e74f2d41aabc2c27db6f2a2a005572c8dd332912
2023-10-23 11:40:41 +02:00
Arda Güçlü c2f0957625 KEP-3638: Promote plugin resolution to beta (#120663)
* Promote plugin resolution to beta

* Not use plugin for kubectl create -f command execution

`kubectl create -f` is legitimate command execution and we shouldn't
search plugins if user invokes this.

* Add integration test for plugin resolution for create command

* Reintroduce feature flag to ability to disable it explicitly

Kubernetes-commit: 074a8b00840e85cc95fd83b1825b14ab21ad09c4
2023-10-23 14:41:38 +03:00
Arda Güçlü 55333c0817 KEP-3895: Promote interactive delete to beta
Kubernetes-commit: e8564d6c5bcf5757238176f90318ae0164274af9
2023-09-05 10:40:12 +03:00
Arda Güçlü 042ec77890 Remove KUBECTL_EXPLAIN_OPENAPIV3 environment variable
Since explain openapiv3 has been moved to beta already, there is no
point to having this environment variable.

This PR removes it.

Kubernetes-commit: 4d8f569b037d2979c1d9c5825e5227aadfc8077f
2023-07-13 13:37:03 +03:00
Arda Güçlü 7e050c1e1d kubectl delete: Introduce new interactive flag for interactive deletion (#114530)
Kubernetes-commit: 3267dd9d5294893580538e98c1e410f64583c0cd
2023-07-11 16:05:11 +03:00
Madhav Jivrajani 56c5264e50 kubectl: Change subresource flag to beta
Signed-off-by: Madhav Jivrajani <madhav.jiv@gmail.com>

Kubernetes-commit: 9fbd08e075dae2b67386fe2c5283f28272858008
2023-03-14 21:44:32 +05:30
Arda Güçlü d3f76f431e Enable plugin resolution as subcommand for selected builtin commands (#116293)
* Enable plugin resolution as subcommand for selected builtin commands

This PR adds external plugin resolution as subcommand for selected builtin
commands if subcommand does not exist as builtin.

In it's alpha stage, this will only be enabled for create command and
this feature is hidden behind `KUBECTL_ENABLE_CMD_SHADOW` environment variable.

* Rename parameter to exactMatch to better reflect

Kubernetes-commit: a901bb630b5a353898c1b35df582a7faeef160a0
2023-03-09 16:16:01 +03:00
Katrina Verey 530dea246b Introduce CLI for ApplySet-based pruning (#115979)
* Introduce CLI for ApplySet-based pruning

* Address feedback from justinsb

* Fix parent namespace sourcing and restrict types. Increase test coverage.

Kubernetes-commit: 0dd346673c00158247c8232f9e81a308fb741463
2023-02-27 12:20:40 -05:00
Jordan Liggitt 21676edd52 Improve kubectl display of invalid errors
Kubernetes-commit: 6c549d75a8d951ec43ecd5394b2634c1a40e5dd1
2022-08-31 11:49:34 -04:00
Marc Khouzam 7ef2d069b5 Add shell completion for new --subresource flag
Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Kubernetes-commit: 33b03096f2fb283f00966350d460e6f4198d4df4
2022-03-28 10:23:54 -04:00
xiaopeng a833054047 replace deprecated setoutput
Kubernetes-commit: 48629bcc0588773bc837d1cc69cab8b21a2057e0
2022-04-05 14:04:22 +08:00
Arda Güçlü ec010ddaa3 Remove redundant validateFlag checks
Kubernetes-commit: 5b274249400157028f1d9107b6bbd0686be2c076
2022-06-13 10:06:51 +03:00
Arda Güçlü aa46caeecd Define NoOptDefVal for validate flag
validate flag does not have default value defined when there is no
parameter passed, therefore it tries to use next irrelevant flag.

This PR defines NoOptDefVal for validate flag which is set "strict".

Kubernetes-commit: 0245e74590a658ea911f1e5cacd270960883af2d
2022-05-06 10:25:40 +03:00
Kevin Delgado 61f42e595f add server-side validation support to kubectl
Kubernetes-commit: fe3772890f650f9bcf020b43dc5a51fab0fa17f4
2022-03-09 14:52:32 +00:00
Yuvaraj Kakaraparthi 38487e770c kubectl: add --support to get, patch, edit and replace commands
Co-authored-by: Nikhita Raghunath <nikitaraghunath@gmail.com>

Kubernetes-commit: a5aa858d44651ba48bdce634a39b55be91216614
2021-07-07 08:30:59 -07:00
Patrick Ohly 7c4cfc5d12 enhance and fix log calls
Some of these changes are cosmetic (repeatedly calling klog.V instead of
reusing the result), others address real issues:

- Logging a message only above a certain verbosity threshold without
  recording that verbosity level (if klog.V().Enabled() { klog.Info... }):
  this matters when using a logging backend which records the verbosity
  level.

- Passing a format string with parameters to a logging function that
  doesn't do string formatting.

All of these locations where found by the enhanced logcheck tool from
https://github.com/kubernetes/klog/pull/297.

In some cases it reports false positives, but those can be suppressed with
source code comments.

Kubernetes-commit: edffc700a43e610f641907290a5152ca593bad79
2022-02-16 12:17:47 +01:00
Eddie Zaneski d76986fd7a Change level for klog.Fatal
Signed-off-by: Eddie Zaneski <eddiezane@gmail.com>

Kubernetes-commit: cd71d3f7881f0c66dbd28aec7af7a0ea0e2acf60
2022-02-10 14:43:19 -07:00
ncapps 9f0231784c Update label selector message to clarify that constraints use AND operator
Kubernetes-commit: 62baa0af4c995cdf401339bfb92d6ae172fe5c6d
2022-01-07 17:25:17 +00:00
Aram Peres 22a27cb97d Add label selector in 'kubectl rollout' commands
Kubernetes-commit: 5a5ac86a80464019e3e85d57306156839511d397
2022-01-06 16:53:29 -05:00
Julian V. Modesto 5c9b92b57c Re-introduce removed kubectl --dry-run values.
For 1.23, we removed the kubectl `--dry-run` empty default value (`--dry-run`)
and boolean values (`--dry-run=true` and `--dry-run=false`). This change
required requiring users to specify `--dry-run=client` or `--dry-run=server`
due to a deprecation. This change was made in #105327.

After reconsideration, this change is not worth the churn for users.
It's likely that many users rely on these values for automated and manual use
cases.

This change reverts #105327 and re-introduces the values `--dry-run`,
`--dry-run=true`, and `--dry-run=false`.

Kubernetes-commit: cc4998b2b131ca9906b847600bd5ad3be70eff3a
2021-12-13 15:04:49 -05:00
yylt 0198d9185e Fix edit command
Kubernetes-commit: 2ae37c8046128e0191ec96c8b31361ae894f2330
2021-10-21 20:07:38 +08:00
brianpursley 07f77100fc Add --override-type flag to kubectl run and kubectl expose to allow the choice of using a JSON Patch or Strategic Merge Patch to apply the override to the generated output.
Kubernetes-commit: 0e697e19ac9f73e2efa0e60157730ba8731e3847
2021-11-05 07:10:47 -04:00
Marc Khouzam b111bee570 Complete multiple resource names
This commit teaches the completion function to repeat resource names
when supported by the command. The logic checks if a resource name
has already been specified by the user and does not include it again
when repeating the completion.

For example, the get command can receive multiple pods names, therefore
with this commit we have:
  kubectl get pod pod1 [tab]
will provide completion of pod names again, but not show 'pod1' since
it is already part of the command-line.

The improvement affects the following commands:
- annotate
- apply edit-last-applied
- apply view-last-applied
- autoscale
- delete
- describe
- edit
- expose
- get
- label
- patch
- rollout history
- rollout pause
- rollout restart
- rollout resume
- rollout undo
- scale
- taint

Note that "rollout status" only accepts a single resource name, unlike
the other "rollout ..." commands; this required the creation of a
special completion function that did not repeat just for that case.

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>

Kubernetes-commit: 7aa5cb40316dbeb970250ee0835fbd597fd19a20
2021-10-15 15:36:09 -04:00
Julian V. Modesto f9ab824bc9 Remove deprecated kubectl --dry-run values.
The boolean values for --dry-run have been deprecated for removal since
1.18, more than 2 releases.

The default value for --dry-run with the flag set and unspecified has
been deprecated for removal since 1.18, more than 2 releases.

Both values are now removed in this change. Any kubectl --dry-run
usage no longer accepts --dry-run=(true|false) boolean values and usage
now requires that a value of (client|server|none) is specified.

Kubernetes-commit: e0b7a85ee5b5d546bec2dc0e8cbf5cd4c0c684d8
2021-09-28 10:03:20 -04:00
BLasan 9072d8b375 Remove AddGeneratorFlag function
Kubernetes-commit: 9c8335b65a4527ea3a07687e4a7a8ba5ebd72041
2021-04-13 23:58:24 +05:30
Katrina Verey 086cadbf87 Create helper for adding chunk-size flag to commands
Kubernetes-commit: f8097c6ceeb16461861c74d4fc5dd0bcd36ebeaf
2021-03-19 08:30:49 -07:00
Katrina Verey 9348b0acca Extract DefaultChunkSize constant
Kubernetes-commit: 222e2c5ef897f4d47831b8d822cab09c000037c2
2021-03-10 12:21:25 -08:00
mengjiao.liu a0af655b7a kubectl default container behavior
Kubernetes-commit: 88e530117ff3fff29e670aee51c677a8e0fe8dec
2021-03-05 17:04:40 +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
pacoxu 4245d9e7b5 print log for default container of kubectl
Kubernetes-commit: 96f8d6262459e802510244d2880886f8b481ee0e
2021-03-01 12:04:29 +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 e650b90b3e Change at which level klog.Fatal is invoked
Kubernetes-commit: 6b4dd3d774bcc84a1f969214096b9cfa373ad389
2020-09-09 21:41:56 +02:00
Julian V. Modesto 0d395d7c98 Make client-side apply safer
- Remove the ServerDryRun field and delegate it entirely to the resource.Helper
- Use resource.Helper for deletions (as in `kubectl apply --force`)
instead of using the pruner's method that uses a dynamic client
- Reduce the resource.Helpers and times we check for server-side dry-run
in apply

Kubernetes-commit: f0eb68c0cfcff6d50d9d5ec278f96820e3cb3f9a
2020-04-02 18:26:32 -04:00
Davanum Srinivas 445ad1366b switch over k/k to use klog v2
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 442a69c3bdf6fe8e525b05887e57d89db1e2f3a5
2020-04-17 15:25:06 -04:00
Julian V. Modesto 415a73888a Set kubectl field manager names
Kubernetes-commit: 360c348d0eb5be8c7c9720d5bfda16dbe04e8d15
2020-03-04 22:04:01 -05:00
Maciej Szulik e576e735d4 Deprecate --generator flag from kubectl create commands
Kubernetes-commit: be6ac856f13b994251b3c8e54b2251cf75c6847d
2020-02-28 11:58:53 +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
Antoine Pelisse 4c36396b35 kubectl-diff: Return non-1 errors on kubectl failures
Currently, diff AND kubectl can return 1 errors either when diff finds
differences, or when kubectl fails something. It also prints an ugly
error when diff finds a differences, since 1 is treated as an error.

Two things this PR does:

1. If diff returns 1, then do not treat it as an error, and exit with
exit code 1. It no longer prints the ugly error.

2. Kubectl errors are +1'd so that they never return 1 which shouldn't
be considered an error.

We need to update the documentation accordingly, to mention that
`KUBECTL_EXTERNAL_DIFF` programs must also follow the convention of
using one as their exit code for changes detected.

Kubernetes-commit: f2b21f08d95291212ba8987aa9d446c02a96089a
2020-01-21 13:52:41 -08:00