7
7
- [ Goals] ( #goals )
8
8
- [ Non-Goals] ( #non-goals )
9
9
- [ Proposal] ( #proposal )
10
- - [ Notes/Constraints/Caveats ] ( #notesconstraintscaveats )
11
- - [ Examples ] ( #examples )
12
- - [ get ] ( #get )
13
- - [ patch ] ( #patch )
10
+ - [ User Stories (Optional) ] ( #user-stories-optional )
11
+ - [ Story 1 ] ( #story-1 )
12
+ - [ Story 2 ] ( #story-2 )
13
+ - [ Risks and Mitigations ] ( #risks-and-mitigations )
14
14
- [ Design Details] ( #design-details )
15
15
- [ Subresource support] ( #subresource-support )
16
16
- [ Table printer] ( #table-printer )
@@ -43,43 +43,44 @@ Items marked with (R) are required *prior to targeting to a milestone / release*
43
43
- [x] (R) KEP approvers have approved the KEP status as ` implementable `
44
44
- [x] (R) Design details are appropriately documented
45
45
- [x] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input (including test refactors)
46
+ - [x] e2e Tests for all Beta API Operations (endpoints)
47
+ - [x] (R) Ensure GA e2e tests meet requirements for [ Conformance Tests] ( https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md )
48
+ - [x] (R) Minimum Two Week Window for GA e2e tests to prove flake free
46
49
- [x] (R) Graduation criteria is in place
50
+ - [x] (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 )
47
51
- [x] (R) Production readiness review completed
48
52
- [x] (R) Production readiness review approved
49
53
- [x] "Implementation History" section is up-to-date for milestone
50
54
- [x] User-facing documentation has been created in [ kubernetes/website] , for publication to [ kubernetes.io]
51
55
- [x] Supporting documentation—e.g., additional design documents, links to mailing list discussions/SIG meetings, relevant PRs/issues, release notes
52
56
53
- <!--
54
- **Note:** This checklist is iterative and should be reviewed and updated every time this enhancement is being considered for a milestone.
55
- -->
56
-
57
57
[ kubernetes.io ] : https://kubernetes.io/
58
58
[ kubernetes/enhancements ] : https://git.k8s.io/enhancements
59
59
[ kubernetes/kubernetes ] : https://git.k8s.io/kubernetes
60
60
[ kubernetes/website ] : https://git.k8s.io/website
61
61
62
62
## Summary
63
63
64
- This KEP proposes supporting a new flag ` --subresource ` to get, patch, edit and replace kubectl
65
- commands to fetch and update ` status ` and ` scale ` subresources.
64
+ This document proposes adding a new ` --subresource ` flag to the following kubectl
65
+ subcommands: ` get ` , ` patch ` , ` edit ` , ` apply ` and ` replace ` . The goal of this flag
66
+ is to simplify the process of fetching and updating ` status ` and ` scale ` subresources.
66
67
67
68
## Motivation
68
69
69
- Today while testing or debugging, fetching subresources (like status) of API objects via kubectl
70
- involves using ` kubectl --raw ` . Patching subresources using kubectl is not possible at all and
71
- requires using curl directly. This method is very cumbersome and not user-friendly.
70
+ Today while testing or debugging, fetching subresources (like ` status ` ) of API objects via kubectl
71
+ involves using ` kubectl --raw ` . Patching subresources using kubectl is not possible at all and
72
+ requires using ` curl ` directly. This method is very cumbersome and not user-friendly.
72
73
73
- This KEP adds subresources as a first class option in kubectl to allow users to work with the API
74
- in a generic fashion.
74
+ This enhancement adds subresources as a first class option in kubectl to allow users
75
+ to work with the API in a generic fashion.
75
76
76
77
### Goals
77
78
78
- - Add a new flag ` --subresource=[subresource-name] ` to get, patch, edit
79
- and replace kubectl commands to allow fetching and updating ` status ` and ` scale `
80
- subresources for all resources (built-in and CRs ) that support these subresources .
81
- - Display pretty printed table columns for the status (uses same columns as the main resource)
82
- and scale subresources.
79
+ - Add a new flag ` --subresource=[subresource-name] ` to ` get ` , ` patch ` , ` edit ` , ` apply `
80
+ and ` replace ` kubectl commands to allow fetching and updating ` status ` and ` scale `
81
+ subresources for all resources (built-in and custom resources ) that support these.
82
+ - Display pretty printed table columns for the ` status ` (uses same columns as the main resource)
83
+ and ` scale ` subresources.
83
84
84
85
### Non-Goals
85
86
@@ -88,25 +89,21 @@ and scale subresources.
88
89
89
90
## Proposal
90
91
91
- kubectl commands like get, patch, edit and replace will now contain a
92
+ kubectl commands like ` get ` , ` patch ` , ` edit ` , ` apply ` and ` replace ` will now contain a
92
93
new flag ` --subresource=[subresource-name] ` which will allow fetching and updating
93
94
` status ` and ` scale ` subresources for all API resources.
94
95
95
- Note that the API contract against the subresource is identical to a full resource. Therefore updating
96
- the status subresource to hold new value which could potentially be reconciled by a controller
97
- to a different value is * expected behavior* .
96
+ Note that the API contract against the subresource is identical to a full resource.
97
+ Therefore updating the status subresource to hold new value which could potentially
98
+ be reconciled by a controller to a different value is * expected behavior* .
98
99
99
- If ` --subresource ` flag is used for a resource that doesn't support the subresource,
100
+ If ` --subresource ` flag is used for a resource that doesn't support the subresource,
100
101
a ` NotFound ` error will be returned.
101
102
102
- ### Notes/Constraints/Caveats
103
103
104
- Due to additional complexity and the general purpose of ` apply ` being a
105
- declarative command, ` --subresource ` will not be expanded to the ` apply ` command.
104
+ ### User Stories (Optional)
106
105
107
- ### Examples
108
-
109
- #### get
106
+ #### Story 1
110
107
111
108
``` shell
112
109
# for built-in types
@@ -142,7 +139,7 @@ $ kubectl get pod nginx-deployment-66b6c48dd5-dv6gl --subresource=scale
142
139
Error from server (NotFound): the server could not find the requested resource
143
140
```
144
141
145
- #### patch
142
+ #### Story 2
146
143
147
144
``` shell
148
145
# For built-in types
@@ -164,6 +161,12 @@ NAME DESIREDREPLICAS AVAILABLEREPLICAS
164
161
cron 3 2
165
162
```
166
163
164
+ ### Risks and Mitigations
165
+
166
+ This feature adds a new flag which will be validated like any other flag for a limited
167
+ set of inputs. The remaining flags passed to every command will be validated as
168
+ before.
169
+
167
170
## Design Details
168
171
169
172
### Subresource support
@@ -182,8 +185,8 @@ If the subresource does not exist for an API resource, a `NotFound` error is ret
182
185
183
186
### Table printer
184
187
185
- To support table view for subresources using kubectl get, table convertor support is added to
186
- the scale and status subresoruces for built-in and CRD types.
188
+ To support table view for subresources using ` kubectl get ` , table convertor support is added to
189
+ the scale and status subresources for built-in and custom resource types.
187
190
188
191
For built-in types, ` StatusStore ` and ` ScaleStore ` are updated to implement the ` TableConvertor ` interface.
189
192
` StatusStore ` uses the same columns as the main resource object.
@@ -193,7 +196,7 @@ The following column definitions for the `Scale` object are added to [printers.g
193
196
- ` Desired Replicas ` uses the json path of ` .spec.replicas ` of autoscalingv1.Scale object
194
197
195
198
For custom resources:
196
- - the status subresoruce uses the same columns as defined for the full resource, i.e., ` additionalPrinterColumns ` defined in the CRD.
199
+ - the status subresource uses the same columns as defined for the full resource, i.e., ` additionalPrinterColumns ` defined in the CRD.
197
200
- the scale subresource follows the same column definitions as the built-in types, and are defined in [ helpers.go] .
198
201
199
202
[ printers.go ] : https://github.com/kubernetes/kubernetes/blob/master/pkg/printers/internalversion/printers.go#L88
@@ -207,45 +210,57 @@ to implement this enhancement.
207
210
208
211
##### Unit tests
209
212
210
- - ` k8s.io/kubernetes/pkg/printers/internalversion ` : ` 2023-01-12 ` - 71.2
211
- - ` k8s.io/kubernetes/vendor/k8s.io/cli-runtime/pkg/resource ` : ` 2023-01-12 ` - 70.9
212
- - ` k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/edit ` : ` 2023-01-12 ` - 100
213
- - ` k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/get ` : ` 2023-01-12 ` - 80.7
214
- - ` k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/patch ` : ` 2023-01-12 ` - 56.3
215
- - ` k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/replace ` : ` 2023-01-12 ` - 63.6
213
+ - ` k8s.io/kubernetes/pkg/printers/internalversion ` : ` 2025-01-23 ` - 73.5
214
+ - ` k8s.io/cli-runtime/pkg/resource ` : ` 2025-01-23 ` - 71.8
215
+ - ` k8s.io/kubectl/pkg/cmd/apply ` : ` 2025-01-23 ` - 82
216
+ - ` k8s.io/kubectl/pkg/cmd/edit ` : ` 2025-01-23 ` - 100
217
+ - ` k8s.io/kubectl/pkg/cmd/get ` : ` 2025-01-23 ` - 80.8
218
+ - ` k8s.io/kubectl/pkg/cmd/patch ` : ` 2025-01-23 ` - 56.4
219
+ - ` k8s.io/kubectl/pkg/cmd/replace ` : ` 2025-01-23 ` - 63.8
216
220
217
221
##### Integration tests
218
222
219
- - ` kubectl get ` : [ link to test coverage] ( https://github.com/kubernetes/kubernetes/blob/4802d7bb62c2623be8e4f940f6b5c1fcddd6c744/test/cmd/get.sh#L178-L184 )
223
+ - [ kubectl get] ( https://github.com/kubernetes/kubernetes/blob/00fa8f119077da3c96090aa5efc5dfc9c5a78977/test/cmd/get.sh#L178-L184 ) : https://storage.googleapis.com/k8s-triage/index.html?pr=1&job=pull-kubernetes-integration&test=test-cmd%3A%20run_kubectl_get_tests
224
+ - [ kubectl apply] ( https://github.com/kubernetes/kubernetes/blob/00fa8f119077da3c96090aa5efc5dfc9c5a78977/test/cmd/apply.sh#L417 ) : https://storage.googleapis.com/k8s-triage/index.html?pr=1&job=pull-kubernetes-integration&test=test-cmd%3A%20run_kubectl_server_side_apply_tests
225
+ - [ TestGetSubresourcesAsTables] ( https://github.com/kubernetes/kubernetes/blob/00fa8f119077da3c96090aa5efc5dfc9c5a78977/test/integration/apiserver/apiserver_test.go#L1458-L1678 ) : https://storage.googleapis.com/k8s-triage/index.html?pr=1&job=pull-kubernetes-integration&test=TestGetSubresourcesAsTables
226
+ - [ TestGetScaleSubresourceAsTableForAllBuiltins] ( https://github.com/kubernetes/kubernetes/blob/ed9572d9c7733602de43979caf886fd4092a7b0f/test/integration/apiserver/apiserver_test.go#L1681-L1876 ) : https://storage.googleapis.com/k8s-triage/index.html?pr=1&job=pull-kubernetes-integration&test=TestGetScaleSubresourceAsTableForAllBuiltins
220
227
221
228
##### e2e tests
222
229
230
+ - [ kubectl subresource flag] ( https://github.com/kubernetes/kubernetes/blob/00fa8f119077da3c96090aa5efc5dfc9c5a78977/test/e2e/kubectl/kubectl.go#L2090-L2118 ) : https://testgrid.k8s.io/sig-testing-canaries#ci-kubernetes-coverage-e2e-gci-gce&include-filter-by-regex=kubectl%20subresource
231
+
223
232
### Graduation Criteria
224
233
225
234
#### Alpha
226
235
227
- - Add the ` --subresource ` flag to get, patch, edit and replace commands .
236
+ - Add the ` --subresource ` flag to ` get ` , ` patch ` , ` edit ` and ` replace ` subcommands .
228
237
- Unit tests and integration tests are added.
229
238
230
239
#### Beta
231
240
232
241
- Gather feedback from users.
233
242
- e2e tests are added.
243
+ - Add the ` --subresource ` flag to ` apply ` subcommand.
234
244
235
245
#### GA
236
246
237
- - User feedback gathered for at least 1 cycle.
247
+ Since v1.27 when the feature moved to beta, there have been no reported bugs concerning this feature.
248
+ In fact, it is reassuring to see the community use this feature quite commonly such as in bug reports:
249
+ https://github.com/kubernetes/kubernetes/issues/116311
238
250
251
+ Seeing this and given our added unit, integration and e2e tests gives us the confidence to graduate to stable.
239
252
240
253
### Upgrade / Downgrade Strategy
241
254
242
- This functionality is contained entirely within kubectl and shares its strategy.
243
- No configuration changes are required.
255
+ See [ Version Skew Strategy] ( #version-skew-strategy ) .
244
256
245
257
### Version Skew Strategy
246
258
247
- Not applicable. There is nothing required of the API Server, so there
248
- can be no version skew.
259
+ The [ kube-apiserver functionality] ( https://github.com/kubernetes/kubernetes/pull/103516 )
260
+ required for the ` --subresource ` flag to work correctly was introduced in Kubernetes v1.24.
261
+ The current release (v1.33) exceeds the [ supported version skew policy] ( https://kubernetes.io/releases/version-skew-policy/ ) .
262
+ Therefore, there are no requirements for planning the upgrade or downgrade process.
263
+ needs to be completed.
249
264
250
265
## Production Readiness Review Questionnaire
251
266
@@ -262,21 +277,21 @@ Pick one of these and delete the rest.
262
277
- Components depending on the feature gate:
263
278
- [x] Other
264
279
- Describe the mechanism: A new flag for kubectl commands.
265
- For the alpha stage, description will be added to expicitly call
280
+ For the alpha stage, description will be added to explicitly call
266
281
out this flag as an alpha feature.
267
282
- Will enabling / disabling the feature require downtime of the control
268
- plane? No, disabling the feature would be a client behaviour .
283
+ plane? No, disabling the feature would be a client behavior .
269
284
- Will enabling / disabling the feature require downtime or reprovisioning
270
- of a node?
271
- No, disabling the feature would be a client behaviour .
285
+ of a node?
286
+ No, disabling the feature would be a client behavior .
272
287
273
288
###### Does enabling the feature change any default behavior?
274
289
275
290
While the feature now updates kubectl's behavior to allow updating subresources,
276
291
it is gated by the ` --subresource ` flag so it does not change kubectl's default
277
292
behavior.
278
293
279
- Subresources can also be updated using curl today so this feature only
294
+ Subresources can also be updated using ` curl ` today so this feature only
280
295
provides a consistent way to use the API via kubectl, but does not allow additional
281
296
changes to the API that are not possible today.
282
297
@@ -287,8 +302,8 @@ for the `--subresource` flag and the ability to update subresources via kubectl.
287
302
288
303
However, this does not "lock" us to any changes to the subresources that were made
289
304
when the feature was enabled i.e. it does not remove the ability to update subresources
290
- for existing API resources completely. If a subresource of an exisiting API resource needs
291
- to be updated, this can be done via curl.
305
+ for existing API resources completely. If a subresource of an existing API resource needs
306
+ to be updated, this can be done via ` curl ` .
292
307
293
308
###### What happens if we reenable the feature if it was previously rolled back?
294
309
@@ -300,31 +315,25 @@ No, because it cannot be disabled or enabled in a single release.
300
315
301
316
### Rollout, Upgrade and Rollback Planning
302
317
303
- <!--
304
- This section must be completed when targeting beta to a release.
305
- -->
306
-
307
318
###### How can a rollout fail? Can it impact already running workloads?
308
319
309
320
The feature is encapsulated entirely within the kubectl binary, so rollout is
310
- an atomic client binary update. Subresources can always be updated via curl,
321
+ an atomic client binary update. Subresources can always be updated via ` curl ` ,
311
322
so there are no version dependencies.
312
323
324
+ For kube-apiserver changes see [ Version Skew Strategy] ( #version-skew-strategy ) .
325
+
313
326
###### What specific metrics should inform a rollback?
314
327
315
328
N/A
316
329
317
330
###### Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?
318
331
319
- This feature is completely with in the client. The upgrades and rollback of cluster will not be affected by this change.
332
+ This feature is completely within the client. The upgrades and rollback of cluster will not be affected by this change.
320
333
The update and downgrade of the kubectl version will only limit the availability of the ` --subresource ` flag and will not
321
334
change any API behavior.
322
335
323
- <!--
324
- Describe manual testing that was done and the outcomes.
325
- Longer term, we may want to require automated upgrade/rollback tests, but we
326
- are missing a bunch of machinery and tooling and can't do that now.
327
- -->
336
+ For kube-apiserver changes see [ Version Skew Strategy] ( #version-skew-strategy ) .
328
337
329
338
###### Is the rollout accompanied by any deprecations and/or removals of features, APIs, fields of API types, flags, etc.?
330
339
@@ -334,14 +343,21 @@ No.
334
343
335
344
###### How can an operator determine if the feature is in use by workloads?
336
345
337
- N/A
346
+ Cluster administrator can verify [ audit entries] ( https://kubernetes.io/docs/tasks/debug/debug-cluster/audit/ )
347
+ looking for ` kubectl ` invocations targeting ` scale ` and ` status ` subresources.
338
348
339
- ###### What are the SLIs (Service Level Indicators) an operator can use to determine the health of the service ?
349
+ ###### How can someone using this feature know that it is working for their instance ?
340
350
341
351
N/A
342
352
343
353
###### What are the reasonable SLOs (Service Level Objectives) for the above SLIs?
344
354
355
+ Since this functionality doesn't heavily modify kube-apiserver I'd expected
356
+ the SLO defined [ here] ( https://github.com/kubernetes/community/blob/master/sig-scalability/slos/slos.md )
357
+ to apply.
358
+
359
+ ###### What are the SLIs (Service Level Indicators) an operator can use to determine the health of the service?
360
+
345
361
N/A
346
362
347
363
###### Are there any missing metrics that would be useful to have to improve observability of this feature?
352
368
353
369
###### Does this feature depend on any specific services running in the cluster?
354
370
355
- No
371
+ No.
356
372
357
373
### Scalability
358
374
388
404
389
405
No
390
406
407
+ ###### Can enabling / using this feature result in resource exhaustion of some node resources (PIDs, sockets, inodes, etc.)?
408
+
409
+ No
410
+
391
411
### Troubleshooting
392
412
393
413
###### How does this feature react if the API server and/or etcd is unavailable?
@@ -404,14 +424,17 @@ N/A
404
424
405
425
## Implementation History
406
426
407
- 2021-03-01: Initial [ POC PR] created
427
+ 2021-03-01: Initial [ POC PR] created
408
428
2021-04-06: KEP proposed
409
429
2021-04-07: [ Demo] in SIG CLI meeting
410
430
2022-05-25: PR for alpha implementation merged
431
+ 2023-01-12: KEP graduated to Beta
432
+ 2023-03-15: e2e test added for KEP as part of beta graduation
433
+ 2025-01-23: KEP graduated to Stable
411
434
412
435
[ POC PR ] : https://github.com/kubernetes/kubernetes/pull/99556
413
436
[ Demo ] : https://youtu.be/zUa7dudYCQM?t=299
414
437
415
438
## Alternatives
416
439
417
- Alternatives would be to use curl commands directly to update subresources.
440
+ Alternatives would be to use ` curl ` commands directly to update subresources.
0 commit comments