Skip to content

Commit cad2c20

Browse files
committed
Changes according to the review
1 parent d76b9b4 commit cad2c20

File tree

3 files changed

+48
-42
lines changed

3 files changed

+48
-42
lines changed

keps/sig-cli/2379-kubectl-plugins/kep.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ creation-date: 2018-07-24
1818
last-updated: 2019-02-26
1919
status: implemented
2020
see-also:
21-
- n/a
21+
- "https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/3638-built-in-command-shadowing"
2222
replaces:
2323
- "https://github.com/kubernetes/community/blob/master/contributors/design-proposals/cli/kubectl-extension.md"
2424
- "https://github.com/kubernetes/community/pull/481"

keps/sig-cli/3638-built-in-command-shadowing/README.md

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,20 @@ tags, and then generate with `hack/update-toc.sh`.
4040
- [Implementation History](#implementation-history)
4141
- [Drawbacks](#drawbacks)
4242
- [Alternatives](#alternatives)
43-
- [Infrastructure Needed (Optional)](#infrastructure-needed-optional)
4443
<!-- /toc -->
4544

4645
## Release Signoff Checklist
4746

4847
Items marked with (R) are required *prior to targeting to a milestone / release*.
4948

50-
- [ ] (R) Enhancement issue in release milestone, which links to KEP dir in [kubernetes/enhancements] (not the initial KEP PR)
49+
- [x] (R) Enhancement issue in release milestone, which links to KEP dir in [kubernetes/enhancements] (not the initial KEP PR)
5150
- [ ] (R) KEP approvers have approved the KEP status as `implementable`
52-
- [ ] (R) Design details are appropriately documented
51+
- [x] (R) Design details are appropriately documented
5352
- [ ] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input (including test refactors)
5453
- [ ] e2e Tests for all Beta API Operations (endpoints)
5554
- [ ] (R) Ensure GA e2e tests meet requirements for [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md)
5655
- [ ] (R) Minimum Two Week Window for GA e2e tests to prove flake free
57-
- [ ] (R) Graduation criteria is in place
56+
- [x] (R) Graduation criteria is in place
5857
- [ ] (R) [all GA Endpoints](https://github.com/kubernetes/community/pull/1806) must be hit by [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md)
5958
- [ ] (R) Production readiness review completed
6059
- [ ] (R) Production readiness review approved
@@ -70,7 +69,7 @@ Items marked with (R) are required *prior to targeting to a milestone / release*
7069

7170
## Summary
7271

73-
This KEP enables external plugins being used as subcommands of built-in `create` command via new `--use-plugin` flag.
72+
This KEP allows external plugins to be used as subcommands of built-in commands when the subcommand does not exist.
7473

7574
## Motivation
7675

@@ -84,44 +83,36 @@ This KEP proposes a viable alternative to users via plugins instead of creating
8483

8584
### Goals
8685

87-
* Enable external plugin usage for `kubectl create` command
86+
* Enable external plugin usage for `kubectl` built-in commands as subcommands, if subcommands does not exist.
8887

8988
### Non-Goals
9089

9190
* Implement a plugin
9291

9392
## Proposal
9493

95-
This KEP introduces a new boolean flag, namely `--use-plugin`. Without this flag, plugin mechanism will work
96-
exactly the way it already works. On the other hand, if the user passes this flag;
94+
When user executes a subcommand of a built-in command, instead returning an "unknown command" error, `kubectl` will search this subcommand
95+
in external plugins with the name structure similar to current plugin search mechanism(e.g. `kubectl-create-foo`).
9796

9897
```sh
99-
$ kubectl foo --use-plugin
100-
(running kubectl-foo plugin without passing --use-plugin flag)
101-
102-
$ kubectl set env --use-plugin
103-
("Error: set command is not allowed for shadowing by plugins")
104-
105-
$ kubectl create job --use-plugin
106-
(running kubectl-create-job plugin without passing --use-plugin flag. If the plugin is not found, failing)
98+
$ kubectl create foo
99+
(running kubectl-create-foo plugin)
107100
```
108101

109-
Being said that `--use-plugin` will be used to force plugin execution and do this only for allowed built-in commands. Currently,
110-
only `create` command will be supported and this list can be extended in future considerations.
102+
If `kubectl` finds a match for the subcommand, it will execute this external plugin how it already does
103+
for external plugins currently.
111104

112-
Because of starting as alpha and this is an explicitly opted-in feature, `--use-plugin` flag is only visible and usable after setting;
105+
Because of starting as alpha and this is an explicitly opted-in feature, shadowing functionality will be hidden behind the environment variable
106+
and will only be used after exporting;
113107
```sh
114108
export KUBECTL_ENABLE_ALPHA_CMD_SHADOW=true
115109
```
116110

117111
### Notes/Constraints/Caveats
118112

119-
In terms of built-in commands, there is not any constraint. Because if user passes the flag, command will be run as plugin regardless
120-
of existed or not. In terms of plugins, this proposal has a notable constraint that `--use-plugin` flag will be removed while
121-
executing plugin. That means that if plugin internally also supports `--use-plugin` flag, flag will not be passed. The reason of
122-
this constraint is that there is no differentiation between user passes `--use-plugin` flag to force plugin usage or actually tries
123-
to pass `--use-plugin` flag to plugin. This can simply be overcome by plugin owners will use different flag naming rather than `--use-plugin`
124-
which is supposed to be special flag in the manner of this proposal.
113+
This KEP in alpha and beta stage will only support shadowing for `kubectl create` to get feedback for other
114+
built-in commands as well. Currently, we know that there are requests for `kubectl create` command but we need to find out
115+
which other built-in commands will also be requested for this shadowing.
125116

126117
### Risks and Mitigations
127118

@@ -188,9 +179,10 @@ https://storage.googleapis.com/k8s-triage/index.html
188179
-->
189180

190181
Tests should include;
191-
- Running `kubectl create CRD` and expects error
192-
- Running `kubectl create CRD --use-plugin` and expect it creates CRD whose plugin should be existed
193-
- Running `kubectl set env --use-plugin` and expects error
182+
- Create custom resource `foo` and `foo2`
183+
- Add external plugin only for `kubectl-create-foo2` in test directory
184+
- Running `kubectl create foo` and expects error
185+
- Running `kubectl create foo2` and expect it creates `foo2` successfully
194186

195187
##### e2e tests
196188

@@ -205,7 +197,9 @@ We expect no non-infra related flakes in the last month as a GA graduation crite
205197
-->
206198

207199
Test should include;
208-
- Create a custom plugin for an example CRD and run `kubectl create CRD --use-plugin` and expects CRD is created
200+
- Add custom plugin `kubectl-create-foo` for custom resource `foo`
201+
- Apply custom resource `foo` into the test cluster
202+
- Execute `kubeectl create foo` command and expects resource is successfully created.
209203

210204
### Graduation Criteria
211205

@@ -235,7 +229,6 @@ functionality is accessed.
235229
[deprecation-policy]: https://kubernetes.io/docs/reference/using-api/deprecation-policy/
236230
237231
Below are some examples to consider, in addition to the aforementioned [maturity levels][maturity-levels].
238-
239232
#### Alpha
240233
241234
- Feature implemented behind a `KUBECTL_ENABLE_ALPHA_CMD_SHADOW=true` environment variable
@@ -245,6 +238,7 @@ Below are some examples to consider, in addition to the aforementioned [maturity
245238
246239
- Gather feedback from developers and surveys
247240
- Add integration tests
241+
- Enable shadowing for all commands
248242
249243
#### GA
250244
@@ -275,6 +269,7 @@ in back-to-back releases.
275269

276270
- Gather feedback from developers and surveys
277271
- Add integration tests
272+
- Enable shadowing for all commands
278273

279274
#### GA
280275

@@ -369,8 +364,7 @@ well as the [existing list] of feature gates.
369364
Any change of default behavior may be surprising to users or break existing
370365
automations, so be extremely careful here.
371366
-->
372-
There would be a breaking change if any of built-in commands have `--use-plugin` flag. But there is none.
373-
If the external plugins use `--use-plugin` flag, their plugins will not get `--use-plugin`'s value.
367+
No, user will continue using their all commands without any change.
374368

375369
###### Can the feature be disabled once it has been enabled (i.e. can we roll back the enablement)?
376370

@@ -384,8 +378,10 @@ feature.
384378
385379
NOTE: Also set `disable-supported` to `true` or `false` in `kep.yaml`.
386380
-->
381+
Yes, we can roll back to a previous release of `kubectl`
387382

388383
###### What happens if we reenable the feature if it was previously rolled back?
384+
Shadowing will continue being supported without any impact on default behavior.
389385

390386
###### Are there any tests for feature enablement/disablement?
391387

@@ -401,6 +397,7 @@ feature gate after having objects written with the new field) are also critical.
401397
You can take a look at one potential example of such test in:
402398
https://github.com/kubernetes/kubernetes/pull/97058/files#diff-7826f7adbc1996a05ab52e3f5f02429e94b68ce6bce0dc534d1be636154fded3R246-R282
403399
-->
400+
No, users can only use this feature via enabling environment variable.
404401

405402
### Rollout, Upgrade and Rollback Planning
406403

@@ -625,6 +622,10 @@ The Troubleshooting section currently serves the `Playbook` role. We may conside
625622
splitting it into a dedicated `Playbook` document (potentially with some monitoring
626623
details). For now, we leave it here.
627624
-->
625+
Built-in commands and subcommands in `kubectl` always overrule external plugins so that it is not possible to shadow
626+
already existing built-ins. Thereby, same troubleshooting mechanism should be applied just troubleshooting
627+
the `kubectl` commands. If the user has a problem when using a plugin, there won't be any change and user needs
628+
to contact with the plugin owner.
628629

629630
###### How does this feature react if the API server and/or etcd is unavailable?
630631

@@ -646,7 +647,7 @@ For each of them, fill in the following information by copying the below templat
646647
###### What steps should be taken if SLOs are not being met to determine the problem?
647648

648649
## Implementation History
649-
650+
The KEP was proposed on 2022-10-22
650651
<!--
651652
Major milestones in the lifecycle of a KEP should be tracked in this section.
652653
Major milestones might include:
@@ -666,16 +667,19 @@ Why should this KEP _not_ be implemented?
666667

667668
## Alternatives
668669

670+
Alternative of the proposed mechanism to overcome this request is to propose a new flag `--use-plugin`. User can
671+
pass this flag when they want to explicitly use the external plugin. Thanks to that, user also can shadow
672+
already existing subcommands. For example `kubectl create job` executes built-in `job` subcommand, on the other hand
673+
`kubectl create job --use-plugin` executes custom `kubectl-create-job` plugin.
674+
675+
However, downside of this alternative is that usability hurts without any gain;
676+
- Everytime user has to pass a new flag to execute external plugin.
677+
- This flag can not be passed to external plugins and this makes `--use-plugin` flag a special flag.
678+
- There is no clear use case allowing plugins for already existed subcommands which means that we want to disable this
679+
deliberately instead providing as a feature.
680+
669681
<!--
670682
What other approaches did you consider, and why did you rule them out? These do
671683
not need to be as detailed as the proposal, but should include enough
672684
information to express the idea and why it was not acceptable.
673685
-->
674-
675-
## Infrastructure Needed (Optional)
676-
677-
<!--
678-
Use this section if you need things from the project/SIG. Examples include a
679-
new subproject, repos requested, or GitHub details. Listing these here allows a
680-
SIG to get the process for these resources started right away.
681-
-->

keps/sig-cli/3638-built-in-command-shadowing/kep.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ authors:
44
- "@ardaguclu"
55
owning-sig: sig-cli
66
status: implementable
7+
see-also:
8+
- "https://github.com/kubernetes/enhancements/tree/master/keps/sig-cli/2379-kubectl-plugins"
79
creation-date: 2023-01-16
810
reviewers:
911
- "@brianpursley"

0 commit comments

Comments
 (0)