Commit graph

866 commits

Author SHA1 Message Date
Marcos Guillermo
6b218dd38b kubectl: Fix panic in exec terminal size queue
Check if delegate is nil before calling Next() in terminalSizeQueueAdapter
to prevent a nil pointer dereference.

Kubernetes-commit: 72a5892dca945f000a30c7a763aa0696964b7e50
2025-12-23 17:37:59 -03:00
Peter Engelbert
52b571c82c Add client-go credential plugin to kuberc
Remove reference to internal types in kuberc types

* Remove unserialized types from public APIs

Also remove defaulting

* Don't do conversion gen for plugin policy types

Because the plugin policy types are explicitly allowed to be empty, they
should not affect conversion. The autogenerated conversion functions for
the `Preference` type will leave those fields empty.

* Remove defaulting tests

Comments and simplifications (h/t jordan liggitt)

Signed-off-by: Peter Engelbert <pmengelbert@gmail.com>

Kubernetes-commit: fab280950dabfefabe6a8578b7a76372a9b21874
2025-10-24 16:06:33 -04:00
Arda Güçlü
cca30abc00 Introduce kuberc view/set commands under kubectl alpha (#135003)
* Introduce kuberc view/set commands under kubectl alpha

* Apply requested changes

* Apply requested changes

Kubernetes-commit: 9cad3f8787606d711ea8890398877fdfab011474
2025-11-05 13:20:31 +00:00
Arda Güçlü
76d6ad851d Add given namespace in dryrun=client output of HPA
Kubernetes-commit: c13c5814597659f84e4af61c642423d37522aec1
2025-09-25 13:15:10 +03:00
Maciej Szulik
72d3fd00c7 Clean NewDefaultKubectlCommandWithArgs for readability
Signed-off-by: Maciej Szulik <soltysh@gmail.com>

Kubernetes-commit: d3c2115441e47a5168a1d5f5dd1207678d71aca8
2025-11-03 11:31:23 +01:00
Maciej Szulik
7a3ec922e4 Move PluginHandler to separate file
Signed-off-by: Maciej Szulik <soltysh@gmail.com>

Kubernetes-commit: ac9120f6076217a6a033cf9a32dd89a61713c59f
2025-11-03 11:25:04 +01:00
Lukasz Szaszkiewicz
17e1b81927 watchlist: wrap remaining LW with ToListWatcherWithWatchListSemantics
Kubernetes-commit: 4fd41778b87a7a02066566cc12e3eb4a87a071ee
2025-10-10 22:44:45 +02:00
Maciej Szulik
164e47abb8 Promote KUBECTL_COMMAND_HEADERS to stable
Signed-off-by: Maciej Szulik <soltysh@gmail.com>

Kubernetes-commit: f82a139dc0840b51aa41931535f5eef6fc3507b4
2025-10-22 13:56:32 +02:00
Ricardo Pchevuzinske Katz
9424fae557 Return error in case of discovery client failure
Kubernetes-commit: f0e88857f7b5d3f56e1296b8c7b38bf4a7eee676
2025-10-23 19:28:18 -03:00
Ondra Kupka
31adc00455 kubectl: Add support for tracing
Kubernetes-commit: 1b863d81c9279449ed4c7cb0ae47c10c0b4010d2
2025-10-23 17:04:30 +02:00
Ondra Kupka
c867eb3934 kubectl: Refactor profiling helpers
Kubernetes-commit: 9d369f32a3de377c1fa0bb5c63cb490fa37038aa
2025-10-23 17:02:02 +02:00
Thomas Hein
3f380f1291 docs: quote PowerShell completion script path ($HOME may contain spaces)
Kubernetes-commit: d7b83193c426ecf4d9a57da5c6d1eeaf838e2946
2025-10-18 04:19:32 -05:00
Thomas Hein
ec5efb5523 docs: dot-source kubectl completion script in PowerShell profile
Kubernetes-commit: 0f6bc57d1189cc7c40d751b6eb59ccdf29f1bcaf
2025-10-18 04:15:34 -05:00
Qiming Teng
89f2922c93 Remove mentioning of the APISelfSubjectReview gate
Kubernetes-commit: 5362c2858de46f2e3f9838e123e9442cafe91315
2025-10-12 16:32:05 +08:00
Maciej Szulik
309b1eff04 Update --chunk-size flag, dropping the beta information
The --chunk-size flag has been around since October 2017
(i4780ad0297)
so it's about time we make it official.

Signed-off-by: Maciej Szulik <soltysh@gmail.com>

Kubernetes-commit: cf099f4fc9028c60e62de33223492d1ef4e03585
2025-10-08 18:13:00 +02:00
Ondra Kupka
d76b915c1a kubectl config set-context: Add -n flag
This is simply a shorthand for --namespace as with other commands.

Kubernetes-commit: d03fab555f1fb77d5045f24bc4cce94ecde2bb98
2025-10-02 17:26:18 +02:00
Arda Güçlü
a06bba9d57 Remove KUBECTL_OPENAPIV3_PATCH feature gate as the feature is stable
Kubernetes-commit: 9382fa8b70be73b0df83d7c2793cf8efd95ec773
2025-09-18 12:30:09 +03:00
rxinui
6f08f37cb1 print the current kubectl command encapsulated by kuberc on V(1)
Signed-off-by: rxinui <rainui.ly@gmail.com>

Kubernetes-commit: cbb7b29bc24f3c1d90f88602855ee3ca0b74d10a
2025-08-17 21:34:03 +02:00
mochizuki875
848d63d832 standardize not found error message of kubectl scale
Kubernetes-commit: bb21080626de5de93e6820e6e22ff5b3dee200f4
2025-09-11 15:45:36 +00:00
Arda Güçlü
93ed510007 Remove redundant experimental prefix in wait command
Kubernetes-commit: 98f81fc291039c96c65b79ef5280d76224084a87
2025-09-05 16:07:54 +03:00
Mayuka Channankaiah
a0eb08a9ac Replace usage of deprecated ErrWaitTimeout with recommended method across all Pkgs
Kubernetes-commit: 6c56d2fd1bc54a7bcda84c8a83428877d9b39e96
2025-08-01 14:18:06 +05:30
Ondra Kupka
5172df9638 kubectl/logs: Add LogOptions.RunLogsContext
LogOptions.RunLogs unfortunately registers a signal handler and calls
os.Exit(1) after finished processing when a signal is received. This
makes it basically impossible to call that function from any custom
code.

This patch adds RunLogsContext, which does exactly what RunLogs does,
but the context to be used is passed in. RunLogs retains the current
contract, but it uses RunLogsContext internally, then calls os.Exit(1)
when a signal is received.

Kubernetes-commit: cc4666cc94be41d8b4558122717a2da9fb5a7b1a
2025-07-18 23:35:24 +02:00
Ondra Kupka
cf8aed98eb cli-runtime: Return defined error from Builder
There is a custom error message returned from resource.Builder when
SingleResourceType is set and multiple resources types are specified,
which makes it impossible to check for the condition in code easily.

This patch adds resource.ErrMultipleResourceTypes that is returned
precisely in this case so that it can be checked.

This patch also removes an extra custom error message in kubectl get,
which is actually never reached, because the builder fails before.

Kubernetes-commit: 82896feebbdf1c0809c0fec29988eff15cb02837
2025-08-04 22:48:57 +02:00
Tim Hockin
21b32eea57 Change KYAML gate to on-by-default
Kubernetes-commit: 5af2b732beeae755c5a87b423659ab46968f4a14
2025-07-30 17:49:33 -07:00
Arda Güçlü
3c19b8deb3 Drop experimental prefix from kubectl wait command
Kubernetes-commit: ff37d8c33945b5c369f40baa1884632cfd0d32c5
2025-08-27 18:36:35 +03:00
Vishnu Mohan
cbe60c952e kubectl: fix expose --selector help text
The current help text wordings incorrectly suggests inference only works for RC/RS when it actually works for Pods and Deployments too

Update help text to accurately reflect that selector inference works
for any resource being exposed, as documented in main expose help.

Kubernetes-commit: 5c8f26f48032899031760e5b75ad259d23d312b2
2025-08-19 01:19:07 +05:30
Caleb Woodbine
12dc58ebf7 chore: update CronJob casing for create job help
use the resource Kind casing for `CronJob` in the note for the `from` argument help

Kubernetes-commit: 76e5929d1a140678f94964142e4cc1566dd1a90c
2025-08-18 11:42:40 +12:00
Benjamin Elder
4b52eef334 fix deprecation formatting for k8s.io/kubectl/pkg/cmd/config.NewCmdConfigSetAuthInfo
Kubernetes-commit: 1dd428d4c0140fd3957c30cb716f710718486aab
2025-08-15 10:55:45 -07:00
Lorain
9e0a26615e fix using stale pod when evict failed and retry (#133461)
* fix using stale pod when evict failed and retry

* simplify pod refresh process

* use activePod at getPodFn

* fix lint check

* add ut

* introduce EvictErrorRetryDelay

Kubernetes-commit: 66fdbe105831e08b588dd01039a7e3130fd2d36f
2025-08-28 04:54:34 +00:00
Mikhail Mazurskiy
ce4d90902a Decouple term and remotecommand packages
This allows consumers of term to not pull in dependencies on
github.com/gorilla/websocket and github.com/moby/spdystream.

Kubernetes-commit: 640dabd58b04b72f646ed85947cb8b407b36dc08
2025-08-03 20:35:40 +10:00
Jordan Liggitt
5c587a03ba Make kubectl auth reconcile retry on conflict
Kubernetes-commit: 3b0a85170a76f419be05c40a866e10c3b760195b
2022-05-28 11:04:14 -04:00
tom1299
403b4a41e8 Fix help for set selector
Kubernetes-commit: 925bce297e4f39a4ab6295416621327773bca5e5
2025-07-07 08:15:52 +02:00
Tim Hockin
02042ef887 Add KYAML support to kubectl
KYAML is a strict subset of YAML, which is sort of halfway between YAML
and JSON.  It has the following properties:
* Does not depend on whitespace (easier to text-patch and template).
* Always quotes value strings (no ambiguity aroud things like "no").
* Allows quoted keys, but does not require them, and only quotes them if
  they are not obviously safe (e.g. "no" would always be quoted).
* Always uses {} for structs and maps (no more obscure errors about
  mapping values).
* Always uses [] for lists (no more trying to figure out if a dash
  changes the meaning).
* When printing, it includes a header which makes it clear this is YAML
  and not ill-formed JSON.
* Allows trailing commas
* Allows comments,
* Tries to economize on vertical space by "cuddling" some kinds of
  brackets together.
* Retains comments.

Examples:

A struct:

```yaml
metadata: {
  creationTimestamp: "2024-12-11T00:10:11Z",
  labels: {
    app: "hostnames",
  },
  name: "hostnames",
  namespace: "default",
  resourceVersion: "15231643",
  uid: "f64dbcba-9c58-40b0-bbe7-70495efb5202",
}
```

A list of primitves:

```yaml
ipFamilies: [
  "IPv4",
  "IPv6",
]
```

A list of structs:

```yaml
ports: [{
  port: 80,
  protocol: "TCP",
  targetPort: 80,
}, {
  port: 443,
  protocol: "TCP",
  targetPort: 443,
}]
```

A multi-document stream:

```yaml
---
{
  foo: "bar",
}
---
{
  qux: "zrb",
}
```

Kubernetes-commit: 2cb955d8ccae30167b9610bfe51c2f86e83a1958
2025-07-14 09:24:18 -07:00
koba1t
fb7d414ec2 Update kubectl kustomize to kyaml/v0.20.1, cmd/config/v0.20.1, api/v0.20.1, kustomize/v5.7.1
Kubernetes-commit: ee8ef383bec15dd63c5d22ffe6a6e0703fc1ba4a
2025-07-23 22:30:05 +09:00
Mayuka Channankaiah
98b4b33964 client-go, kubectl: Replace deprecated ErrWaitTimeout with recommended method (#132718)
* client-go: Replace depracted ErrWaitTimeout with recommended method

* Fix UT and Integration tests

* IT test

Kubernetes-commit: ffe306d67958297202e9492ea644b42c0e7e694d
2025-07-24 19:32:01 +00:00
Dharmit Shah
3cb662b4be JSON & YAML output for kubectl api-resources (#132604)
* Add JSON & YAML output support for kubectl api-resources

Create a separate `PrintFlags` struct within the apiresources.go file
that handles printing only for `kubetl api-resources` because existing
output formats, i.e., wide and name, are already implemented
independently from HumanReadableFlags and NamePrintFlags.

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

* Use separate printer type for all options

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

* Unit tests for JSON & YAML outputs

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

* Separate file for print types

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

* Move JSON-YAML tests to separate function

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

* Fix broken unit test

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

* Unifying JSON & YAML unit test functions

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

* Fix linter errors

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

* PR feedback and linter again

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

---------

Signed-off-by: Dharmit Shah <shahdharmit@gmail.com>

Kubernetes-commit: cb33accc8fc4d44e902da4926eee7b828c5e51ec
2025-07-24 15:35:50 +00:00
Davanum Srinivas
f47e5c84cc Bump k8s.io/kube-openapi to latest SHA (f3f2b991d03b)
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: ebc1ccc491c944fa0633f147698e0dc02675051d
2025-07-10 09:21:52 -04:00
Gemma Hou
76e6818d8d Improve ignore-not-found behavior (#132542)
* Improve ignore-not-found behavior

* ignore lint errcheck

Kubernetes-commit: a7e8a505c25965c074f2b10b1bf40230eca48a08
2025-07-03 01:53:24 +00:00
Ondra Kupka
edad3048e9 kubectl: Cache Verifier.HasSupport calls
The underlying implementation decodes OpenAPI schema on every HasSupport
call. This causes these calls to be expensive and noticable when many
resources are being applied.

This patch wraps the verifier with a thread-safe cache so that when many
resources of the same kind are being checked, only the first call
includes schema decoding.

This solution is specifically limited to the kubectl codebase without
any changes required in client-go, for now, although that is where the
issue is actually originating.

Kubernetes-commit: 9043afae6d98585dd14d203d48807b14b433d730
2025-05-23 21:58:05 +02:00
Kurnia D Win
4b5ec542ad feat: kubectl debug: add label for debugger pod
Kubernetes-commit: e9fcdabcf5072de662d9c02f83df5f0ac80c2a43
2025-05-15 17:32:06 +07:00
Janet Kuo
daa78b3004 Enhance help text for the 'top' command
* Detailing the metrics source
* Connecting to HPA
* Defining its scope

Kubernetes-commit: e54e01e0abbff795a5628f2e845c815e6d43c03f
2025-06-26 16:53:50 -07:00
googs1025
e33a30ea7c feature(kubectl): support mem-percent,cpu-value,cpu-average-value,mem-value,mem-average-value flag to kubectl autoscale
Signed-off-by: googs1025 <googs1025@gmail.com>

Kubernetes-commit: 6795d5366f11b7bc782223beaa4f81bef04f751c
2024-12-24 10:01:25 +08:00
Davanum Srinivas
7e06b5277c switch to latest sigs.k8s.io/yaml v1.5.0 (run update-gofmt.sh as well)
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: c5b4b133ce3252ee19b7167eb69a99d88fdefda8
2025-06-25 08:03:06 -04:00
Davanum Srinivas
a6fde79de4 Drop usage of forked copies of goyaml.v2 and goyaml.v3
Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: 3827d3bc4f1c17ac816b37422dbd449c276e9ff0
2025-06-17 11:00:27 -04:00
totegamma
2fa4a24584 show namespace on delete (#126619)
* show namespace on delete

* update kubectl delete message

* add test 'TestDeleteMessageOutput'

* update delete_test.go

Kubernetes-commit: 75862f3f461b8c83f3cbbf441ce4fd5357d3bba0
2025-06-24 02:15:09 +00:00
Arda Güçlü
8a11631ed9 kubectl delete: Update interactive delete to break on new line
Kubernetes-commit: fb611f4c93e6d8d8eb920f4436af748432402f50
2025-06-12 11:27:51 +03:00
Itamar Holder
0b4adb247f [KEP-2400] kubectl top: add a --show-swap option (#129458)
* top, refactor: turn package-exposed variables to unexpose struct fields

Signed-off-by: Itamar Holder <iholder@redhat.com>

* kubectl top node: add the --show-swap option

Example output:
> kubectl top node --show-swap
NAME     CPU(cores)   CPU(%)   MEMORY(bytes)   MEMORY(%)   SWAP(bytes)   SWAP(%)
node01   500m         8%       2836Mi          60%         0Mi           0%
node02   260m         5%       2206Mi          47%         512Mi         50%

Signed-off-by: Itamar Holder <iholder@redhat.com>

* kubectl top pod: add the --show-swap option

Example output:
> kubectl top pod -n kube-system --show-swap
NAME                                      CPU(cores)   MEMORY(bytes)   SWAP(bytes)
coredns-58d5bc5cdb-5nbk4                  2m           19Mi            0Mi
coredns-58d5bc5cdb-jsh26                  3m           37Mi            0Mi
etcd-node01                               51m          143Mi           0Mi
kube-apiserver-node01                     98m          824Mi           0Mi
kube-controller-manager-node01            20m          135Mi           0Mi
kube-proxy-ffgs2                          1m           24Mi            0Mi
kube-proxy-fhvwx                          1m           39Mi            0Mi
kube-scheduler-node01                     13m          69Mi            0Mi
metrics-server-8598789fdb-d2kcj           5m           26Mi            0Mi

Signed-off-by: Itamar Holder <iholder@redhat.com>

* kubectl top node --show-swap: add unit tests

Signed-off-by: Itamar Holder <iholder@redhat.com>

* kubectl top pod --show-swap: Add unit tests

Signed-off-by: Itamar Holder <iholder@redhat.com>

* Explicitly mark swap as unavailable when necessary

Signed-off-by: Itamar Holder <iholder@redhat.com>

---------

Signed-off-by: Itamar Holder <iholder@redhat.com>

Kubernetes-commit: 8d3fb9ee0a51b6a6ea135d991391c35806422c19
2025-06-04 17:10:38 +03:00
Stephen Kitt
abe43f6e92 kubectl: drop dependency on github.com/pkg/errors
The package is unmaintained, and kubectl doesn't rely on the
functionality it provides on top of Golang errors (stack traces).

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

Kubernetes-commit: 54b2fad0330032ae1bbac990f93a3644aa8a12af
2025-05-26 10:44:46 +02:00
Kazuki Suda
bb9c5182ea Revert shorthand for kubectl explain --output
Kubernetes-commit: df2857e7777f18c482359cfb43a72a3cdfd89646
2025-05-26 12:16:24 +09:00
Arda Güçlü
ca5a831a47 Promote kuberc to beta
Signed-off-by: Maciej Szulik <soltysh@gmail.com>

Kubernetes-commit: b0370c483af1bdbc1e2664f53445411c585c4559
2025-05-06 12:52:20 +03:00