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,53 +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
223
- - e2e test added:
224
- - [ Link to testgrid] ( https://testgrid.k8s.io/sig-testing-canaries#ci-kubernetes-coverage-e2e-gci-gce&include-filter-by-regex=kubectl%20subresource )
225
- - [ Link to test] ( https://github.com/kubernetes/kubernetes/blob/11b974043604f5ccbeb6e5e62e1d9edcf00bc336/test/e2e/kubectl/kubectl.go#L2101 )
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
226
231
227
232
### Graduation Criteria
228
233
229
234
#### Alpha
230
235
231
- - Add the ` --subresource ` flag to get, patch, edit and replace commands .
236
+ - Add the ` --subresource ` flag to ` get ` , ` patch ` , ` edit ` and ` replace ` subcommands .
232
237
- Unit tests and integration tests are added.
233
238
234
239
#### Beta
235
240
236
241
- Gather feedback from users.
237
242
- e2e tests are added.
243
+ - Add the ` --subresource ` flag to ` apply ` subcommand.
238
244
239
245
#### GA
240
246
241
247
Since v1.27 when the feature moved to beta, there have been no reported bugs concerning this feature.
242
248
In fact, it is reassuring to see the community use this feature quite commonly such as in bug reports:
243
- https://github.com/kubernetes/kubernetes/issues/116311
244
-
245
- Seeing this and given our added unit, integration and e2e tests gives us the confidence to graduate to GA.
249
+ https://github.com/kubernetes/kubernetes/issues/116311
246
250
251
+ Seeing this and given our added unit, integration and e2e tests gives us the confidence to graduate to stable.
247
252
248
253
### Upgrade / Downgrade Strategy
249
254
250
- This functionality is contained entirely within kubectl and shares its strategy.
251
- No configuration changes are required.
255
+ See [ Version Skew Strategy] ( #version-skew-strategy ) .
252
256
253
257
### Version Skew Strategy
254
258
255
- Not applicable. There is nothing required of the API Server, so there
256
- 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.
257
264
258
265
## Production Readiness Review Questionnaire
259
266
@@ -270,21 +277,21 @@ Pick one of these and delete the rest.
270
277
- Components depending on the feature gate:
271
278
- [x] Other
272
279
- Describe the mechanism: A new flag for kubectl commands.
273
- For the alpha stage, description will be added to expicitly call
280
+ For the alpha stage, description will be added to explicitly call
274
281
out this flag as an alpha feature.
275
282
- Will enabling / disabling the feature require downtime of the control
276
- plane? No, disabling the feature would be a client behaviour .
283
+ plane? No, disabling the feature would be a client behavior .
277
284
- Will enabling / disabling the feature require downtime or reprovisioning
278
- of a node?
279
- No, disabling the feature would be a client behaviour .
285
+ of a node?
286
+ No, disabling the feature would be a client behavior .
280
287
281
288
###### Does enabling the feature change any default behavior?
282
289
283
290
While the feature now updates kubectl's behavior to allow updating subresources,
284
291
it is gated by the ` --subresource ` flag so it does not change kubectl's default
285
292
behavior.
286
293
287
- 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
288
295
provides a consistent way to use the API via kubectl, but does not allow additional
289
296
changes to the API that are not possible today.
290
297
@@ -295,8 +302,8 @@ for the `--subresource` flag and the ability to update subresources via kubectl.
295
302
296
303
However, this does not "lock" us to any changes to the subresources that were made
297
304
when the feature was enabled i.e. it does not remove the ability to update subresources
298
- for existing API resources completely. If a subresource of an exisiting API resource needs
299
- 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 ` .
300
307
301
308
###### What happens if we reenable the feature if it was previously rolled back?
302
309
@@ -308,54 +315,48 @@ No, because it cannot be disabled or enabled in a single release.
308
315
309
316
### Rollout, Upgrade and Rollback Planning
310
317
311
- <!--
312
- This section must be completed when targeting beta to a release.
313
- -->
314
-
315
318
###### How can a rollout fail? Can it impact already running workloads?
316
319
317
320
The feature is encapsulated entirely within the kubectl binary, so rollout is
318
- 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 ` ,
319
322
so there are no version dependencies.
320
323
324
+ For kube-apiserver changes see [ Version Skew Strategy] ( #version-skew-strategy ) .
325
+
321
326
###### What specific metrics should inform a rollback?
322
327
323
328
N/A
324
329
325
330
###### Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?
326
331
327
- 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.
328
333
The update and downgrade of the kubectl version will only limit the availability of the ` --subresource ` flag and will not
329
334
change any API behavior.
330
335
331
- <!--
332
- Describe manual testing that was done and the outcomes.
333
- Longer term, we may want to require automated upgrade/rollback tests, but we
334
- are missing a bunch of machinery and tooling and can't do that now.
335
- -->
336
+ For kube-apiserver changes see [ Version Skew Strategy] ( #version-skew-strategy ) .
336
337
337
338
###### Is the rollout accompanied by any deprecations and/or removals of features, APIs, fields of API types, flags, etc.?
338
339
339
340
No.
340
341
341
342
### Monitoring Requirements
342
343
343
- Considering that this feature is a flag contained fully within in the ` kubectl ` client, there exist no
344
- monitoring requirements for the same.
345
-
346
344
###### How can an operator determine if the feature is in use by workloads?
347
345
348
- 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.
349
348
350
349
###### How can someone using this feature know that it is working for their instance?
351
350
352
351
N/A
353
352
354
- ###### What are the SLIs (Service Level Indicators) an operator can use to determine the health of the service ?
353
+ ###### What are the reasonable SLOs (Service Level Objectives) for the above SLIs ?
355
354
356
- N/A
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.
357
358
358
- ###### What are the reasonable SLOs (Service Level Objectives) for the above SLIs ?
359
+ ###### What are the SLIs (Service Level Indicators) an operator can use to determine the health of the service ?
359
360
360
361
N/A
361
362
367
368
368
369
###### Does this feature depend on any specific services running in the cluster?
369
370
370
- No
371
+ No.
371
372
372
373
### Scalability
373
374
@@ -423,17 +424,17 @@ N/A
423
424
424
425
## Implementation History
425
426
426
- 2021-03-01: Initial [ POC PR] created
427
+ 2021-03-01: Initial [ POC PR] created
427
428
2021-04-06: KEP proposed
428
429
2021-04-07: [ Demo] in SIG CLI meeting
429
430
2022-05-25: PR for alpha implementation merged
430
431
2023-01-12: KEP graduated to Beta
431
432
2023-03-15: e2e test added for KEP as part of beta graduation
432
- 2024-02-01 : KEP graduated to Stable
433
+ 2025-01-23 : KEP graduated to Stable
433
434
434
435
[ POC PR ] : https://github.com/kubernetes/kubernetes/pull/99556
435
436
[ Demo ] : https://youtu.be/zUa7dudYCQM?t=299
436
437
437
438
## Alternatives
438
439
439
- 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