Commit Graph

121 Commits

Author SHA1 Message Date
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
Jordan Liggitt 722397942b Drop null creationTimestamp from test fixtures
Kubernetes-commit: 6bb6c9934294d8265197c9dfc4c9dd3adaca147a
2025-03-24 09:37:26 -04:00
Omer Aplatony 2bb31e1a0f Replace PollImmediate with PollUntilContextTimeout (#128147)
* Replace PollImmediate with PollUntilContextTimeout

Signed-off-by: Omer Aplatony <omerap12@gmail.com>

* Add context to RetryErrorCondition function

Signed-off-by: Omer Aplatony <omerap12@gmail.com>

* lint: fix error comparison in scale package

Signed-off-by: Omer Aplatony <omerap12@gmail.com>

* Fix RetryErrorCondition function signature

Signed-off-by: Omer Aplatony <omerap12@gmail.com>

* revert to if err statement

Signed-off-by: Omer Aplatony <omerap12@gmail.com>

---------

Signed-off-by: Omer Aplatony <omerap12@gmail.com>

Kubernetes-commit: 9d816f1587c918e7acae6d9195d33606aec998b1
2024-11-07 16:57:29 +02:00
Anish Shah b22c40d47c kubectl: remove subresource restrictions from all commands
Removing this restrictions will allow us to use these commands with the
new resize subresource.

Kubernetes-commit: e1ca63489f2b788f893ab37a27242ce319e1eaf6
2024-10-31 16:00:52 -07:00
David Eads d6ad8b12b7 add --subresource to kubectl apply
Kubernetes-commit: 55ba8b2cbb375aaedcd01dd5d4dd0f81ef0415bf
2024-09-25 17:23:09 -04:00
Tobias Klauser d80cbcdb4d Use Go standard library slices package instead of k8s.io/utils/strings/slices
The package was introduced in Go 1.21 and is already in use in the k8s
code base.

Kubernetes-commit: 23dcd2604883c7ba91d72f5a9d84706650260c55
2024-08-15 14:43:53 +02:00
Matthieu MOREL 1a58d7f437 fix: enable empty and len rules from testifylint on pkg package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Co-authored-by: Patrick Ohly <patrick.ohly@intel.com>

Kubernetes-commit: f014b754fb5925dfbca6e27a44d0c3968b157e14
2024-06-28 21:20:13 +02:00
Jordan Liggitt 81ad0ffc39 Prune explicit nulls from client-side apply create
Kubernetes-commit: 8483b9c08763c8f615216e95efdde46d5c7f6ef7
2024-05-29 01:14:18 -04:00
Brian Pursley 8d8b5a6120 Use ptr.To instead of deprecated pointer functions
Kubernetes-commit: 288d132cf62efe029b6359c600565f8c7b12647d
2024-05-20 16:14:54 -04:00
Brian Pursley 852454f7f7 Improve performance of TestForceApply unit test.
Change backOffPeriod from const to var, so that it can be set lower during unit test.

Kubernetes-commit: f011ed5ca5b23971f2dc620971b3b5bebb346b84
2024-04-23 22:04:38 -04:00
Jefftree d8e26d70e5 Make OpenAPIGetter tolerant of nil
Kubernetes-commit: 9d1829c33ac457d2c803ff900f67df03af50fa94
2023-12-15 13:44:54 -05: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
Jefftree 03a47d93ec use OpenAPIV3 for kubectl diff
Kubernetes-commit: e7216c6623049d713fbf7cc04e2c42eb957a607e
2023-09-15 17:53:10 -04:00
Jefftree 8b0ab9a40e Use OpenAPI V3 for client side SMP
Kubernetes-commit: 4f3b0b15182d80b02d7a7bd2c210c145b7552f82
2023-09-15 16:46:53 -04:00
justinsb eda2d31bdd kubectl prune v2: switch to contains-group-kinds annotation
The contains-group-resources was an implementation error, we specified
contains-group-kinds in the KEP.

Because it is in alpha, we simply switch to the new annotation.

We will recognize the old annotation and migrate existing alpha
applysets, but support for this migration can be removed in beta/GA of
applyset.

Kubernetes-commit: 10caecb3b22cf93c7caa2ac70d40af9b550c0da2
2023-06-28 11:27:00 -04:00
Andrea Hoffer b676723184 Update CLI help text for grammar and consistency
Kubernetes-commit: a86380c7813a6d0cfa248c9165c878038730526a
2023-06-12 15:55:59 -04:00
Arda Güçlü 3f05cfcd78 Migrate genericclioptions.IOStreams usage to genericiooptions
Kubernetes-commit: 00c30941260a27e6929aef84c7fdbc8f1508518c
2023-04-05 14:07:46 +03:00
Katrina Verey 03f092a1af Use standard *.kubernetes.io instead of *.k8s.io for ApplySet
Kubernetes-commit: a0cff30104ea950a5cc733a109e7f9084275e49e
2023-03-20 18:21:04 -04:00
justinsb 11dbc9b97f prunev2: find resources in parallel
To improve wall-clock speed, we run list operations in parallel.  This
particularly helps when the round-trip time is high.

We issue requests as quickly as possible, kube-apiservers should all
have priority and fairness at this point and we don't want to
duplicate/fight that system.

Kubernetes-commit: 82eee59d0feb4b303e6ef78ebb7ec646a059f266
2023-03-14 12:45:45 +00:00
justinsb 62b0fbdb7a kubectl prunev2: Refactor the applyset to be more reusable
This enables sharing with diff.

Kubernetes-commit: d016fdcc834099dee721f42a384e1bc1f710e599
2023-03-14 12:12:00 +00:00
Katrina Verey a038484b5c Allow conformant CRDs to be ApplySet parents
Kubernetes-commit: 923d9b63fd87e9446f5746f544237c7e0de009a0
2023-03-07 11:29:50 -05:00
Katrina Verey ca98377c3e Applyset dry run tests + ID value (#116265)
* Test for ApplySet with --dry-run=client|server

* Use the real format for ApplySet ID

* Incorporate feedback

* Adjustments from rebase

Kubernetes-commit: 6a31757f45693fec5ea4723bcb405ce4437e31ca
2023-03-15 11:17:56 +00:00
Justin SB 0567f1e464 prunev2: Implement basic pruning
Implement the basic prune strategy where we find-by-label and then
delete unknown objects.

Kubernetes-commit: f17a319dc60374a46be1b37a453227d134ac479e
2023-02-22 21:40:25 -05:00
Katrina Verey 250ef6fa54 Feedback and linter
Kubernetes-commit: 3b0e13482e4459f9cb6a006cac2da76333992efd
2023-03-03 11:50:16 -05:00
Katrina Verey a04ac8a907 Create and update the ApplySet parent object
Kubernetes-commit: 7f874c91017eefd12df3d824793ab7e9b0be088e
2023-02-27 18:40:59 -05:00
Justin SB a7db218701 cleanup: replace deprecated sets.String
Replace with generics, including using the more-accurate type
types.UID for visitedUids.

Kubernetes-commit: 0b5fa1934250307c4df7c6bcabf6a6b1b00e73d9
2023-03-01 09:05:59 -05:00
Justin SB 78b973156e prunev2: Add labels for objects that we apply
As we apply objects when using apply/prune v2, we want to be sure they
include the label that ties them back to the applyset they are part
of.

Co-Authored-By: Katrina Verey <katrina.verey@shopify.com>

Kubernetes-commit: ab058308401b35b4865424cfa43ed75a554af2a3
2023-02-22 22:06:48 -05: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
Sean Sullivan 99206f74b9 Removes kube-openapi dependency from Patcher
Kubernetes-commit: 34aa661eed606fd049f79a12ab3344f5093811fa
2023-01-09 19:13:30 -08:00
Sean Sullivan 7efcc7e0ac Fixes prune for server-side applied objects
Kubernetes-commit: 21393f1b1d859cecdcc9aeee01f7dbf9aab71120
2022-10-25 21:59:31 +00:00
Chok Yip Lau de2d479b98 fixed error
Kubernetes-commit: 65eb7f1e0c452a0ce00d9db874c54a5de2932564
2022-12-18 22:58:23 -05:00
Chok Yip Lau 3fea4735ad Removed factory from apply command flag struct
Kubernetes-commit: cdd84a28bfc2e1e7ad552de128cd1644c7deeae7
2022-11-20 15:53:05 -05:00
Sean Sullivan 7c10c1c878 Unexport OpenAPIGetter factory method
Kubernetes-commit: 1da46b2f28267421dad9a8e5164e6bce16ae9fcb
2022-12-12 16:01:05 -08:00
Sean Sullivan e5c05deb7b Refactor to simplify factory Validator
Kubernetes-commit: 5e8648b9f1cdbcbb10f22fd46b6ac40dbc471de2
2022-12-11 18:20:28 -08:00
Sean Sullivan 6dde41fea6 Removes unnecessary dry run verifier
Kubernetes-commit: 530f65d6fd5af81c0691143fbf2c00d440476bb9
2022-12-05 16:25:12 -08:00
inosato 8272d71ba6 Remove ioutil from kubectl
Signed-off-by: inosato <si17_21@yahoo.co.jp>

Kubernetes-commit: 774ab1349bfd553c97a99b992e9f38659f541c84
2022-07-30 22:31:16 +09:00
Paco Xu 6c2e12e0be kubectl-apply: add prune test cases for non-namespaced resources
Signed-off-by: Paco Xu <paco.xu@daocloud.io>

Kubernetes-commit: 7263aba71bfdd2286200ffd7ef79766950c5fcd9
2022-11-09 07:43:43 +08:00
Paco Xu 89470f4910 kubectl apply: warning that in future release, prune will ignores no-namespaced resource if -n is not empty
Signed-off-by: Paco Xu <paco.xu@daocloud.io>

Kubernetes-commit: f3b49adadf2182ba0a7fb930e6340da725053520
2022-11-09 07:43:03 +08:00
Brian Pursley 41407b14e8 kubectl apply: Deprecate --prune-whitelist in favor of --prune-allowlist
Changes in kubectl apply --prune to support k8s Inclusive Naming Initiative:
* Deprecated the --prune-whitelist flag.
* Deprecated the PruneWhitelist field on ApplyFlags struct.
* Removed PruneWhitelist field (not used anywhere) from ApplyOptions struct.
* Added --prune-allowlist flag.
* Added PruneAllowlist field on ApplyFlags struct.
* Added unit tests for prune with allowlist

This commit also fixes a bug where the command would fail if you specified
the sameGVK multiple times for --allow-whitelist. Now it only attempts to
prune the unique set of allowed GVKs.

Kubernetes-commit: f7ebf4d8852d4500f24100ca9a4ca665efc1fada
2022-10-30 20:50:19 -04:00
Alexander Zielenski 4f1b2184e0 add kubectl server-side apply migrate managedfields
in discussion with SIG, there is a strong interest in keeping the last-applied-configuration around for a bit longer as other tools transition for of it. This is OK since SSA maintains the annotation on kubectl's behalf on the server-side if it exists

migrate client-side-apply fields to SSA when --serverside-side is used

https://github.com/kubernetes/kubernetes/issues/107980

https://github.com/kubernetes/kubernetes/issues/108081

https://github.com/kubernetes/kubernetes/issues/107417

https://github.com/kubernetes/kubernetes/issues/112826

add test to make sure only one apply is needed after migration

Kubernetes-commit: 33b9552e708154c20144c7aca921ad239527fb2f
2022-11-03 20:14:37 -07:00
Arda Güçlü 89edfadfa3 Use OpenAPI to determine patch type in kubectl apply patching
Currently `kubectl apply` determines correct patch type for given
GVKs by trying to register schema and if it succeeds, it uses
strategic-merge-patch.

But OpenAPI endpoint already stores which patch types are supported
by GVKs. This PR checks OpenAPI endpoint to retrieve patch type,
if OpenAPI is enabled. If it is not enabled, patch type determination
will be done as conventional registration method.

Kubernetes-commit: cddbb0c56397448ac0489f0473a26601c1feece8
2022-06-08 13:12:16 +03:00
peizhouyu 975bff8512 fix that beginning of help text is cut off for apply and replace --filename flag
Kubernetes-commit: d216b3433d018fae95efdf987002dd8c4d006ae6
2022-07-28 11:33:34 +08:00
Sean Sullivan e23896b42c gofmt update
Kubernetes-commit: d84abe868d673de917b5714cd2460f21413ac745
2022-07-24 23:46:44 -07:00
Sean Sullivan acec06e5c9 disallow --force and --prune in client-side apply
Kubernetes-commit: e02a26d74a2e346b4a5607c99180e5b748923e5f
2022-07-24 16:26:57 -07:00
Arda Güçlü f95d534f9d Move resource lookup into its own function
Kubernetes-commit: 66c2f6069ebbfa41d0bef0f3959abda59b8483f1
2022-06-28 09:30:06 +03:00
Arda Güçlü df792c788b Use error wrapping in patchSimple
Kubernetes-commit: 22b43d4edbee4f89984d1b905adb1f905f3ab90b
2022-06-22 10:22:27 +03:00
Arda Güçlü b19c7e78f3 Move getPatchType logic back to main function
Kubernetes-commit: 4ed5653a0bc8ca53ca6a917e634457bd7a2d8dae
2022-06-22 09:35:49 +03:00
Arda Güçlü 351ebce2c4 Stop passing source as parameter
This commit removes passing source field as parameter. Instead,
this commit returns error verb and error functions to caller function.
Caller function can add source field by generating correct message.

Kubernetes-commit: d336f7df874dc978ebd97971e1fc93d891c21e7d
2022-06-20 10:04:18 +03:00