-
Notifications
You must be signed in to change notification settings - Fork 1.6k
kubectl subresource KEP #2600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kubectl subresource KEP #2600
Conversation
|
/cc @eddiezane @soltysh @seans3 @pwittrock /assign @eddiezane |
|
/assign @soltysh |
|
Demo of this from sig-cli bi-weekly https://youtu.be/zUa7dudYCQM?t=299. |
| ```shell | ||
| # For built-in types | ||
| # update spec.replicas through scale subresource | ||
| $ kubectl patch deployment nginx-deployment --subresource='scale' --type='merge' -p '{"spec":{"replicas":2}}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the actual benefit of doing that though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ability to modify the scale subresource was added to be consistent with the similar behavior provided to the status subresrouce.
@nikhita if you had any specific uses cases for modifying scale, we should document them in the KEP.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than convenience I don't see much value, but I won't object either.
|
|
||
| ```shell | ||
| # cron-with-status.yaml has .status.replicas=3 | ||
| $ kubectl apply -f cron-with-status.yaml --subresource=status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will override the last-applied annotation set by another kubectl apply occurence (probably on main resource), which will result in odd behaviors later. Also note that some resources don't allow annotations to be updated through status subresource. That would probably work with server-side apply.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This potentially odd behavior was brought up during the SIG-CLI demo too. I am currently investigating what should be done to handle this properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was another question I brought during the call, if the argument contains just status or full object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when using apply with subresource it turns out the last-applied annotation is not modified. The annotation is under the metadata section and that section and any changes to the updates are ignored when modifying the subresources.
Therefore any subsequent apply calls to the resource itself are not affected as the patch calculated for the apply call will use the correct last-applied configuration of resource.
The same cannot be said when apply-ing a subresource. The patch calculated using the annotation could be wrong because the last applied configuration of the status is not captured in the annotation.
| ```shell | ||
| # For built-in types | ||
| # update spec.replicas through scale subresource | ||
| $ kubectl patch deployment nginx-deployment --subresource='scale' --type='merge' -p '{"spec":{"replicas":2}}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than convenience I don't see much value, but I won't object either.
|
|
||
| ```shell | ||
| # cron-with-status.yaml has .status.replicas=3 | ||
| $ kubectl apply -f cron-with-status.yaml --subresource=status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was another question I brought during the call, if the argument contains just status or full object?
|
@soltysh I have address all the comments on the comments. Please take a look :) |
0b82453 to
7a906c0
Compare
| - [ ] Feature gate (also fill in values in `kep.yaml`) | ||
| - Feature gate name: | ||
| - Components depending on the feature gate: | ||
| - [x] Other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does the user know it's alpha?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have an explicit mechanism for stating if a flag is alpha or not, there are a couple of approaches:
- Use
alphaprefix in the flag name, but I personally don't like that approach since it means we will have to change flag name eventually. - Force using env var, which allows this flag.
- Hiding the flag by default, similarly to how deprecated flags are hidden.
- Providing a description which is explicitly calling out it's alpha.
I'm personally leaning towards 3 or 4, and given this is an explicit opt-in (you need to place the flag when invoking kubectl command) I'm not worried that users will have issues with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for having a description explicitly calling out it's alpha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, can you pick whatever mechanism is preferred by the SIG and document it here. I don't have a preference really. Otherwise all looks good for PRR, I will approve after that change and the SIG approves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to option 4 (description explicitly calling out as alpha) and squashed the commits. PTAL :)
soltysh
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
from sig-cli pov
| - [ ] Feature gate (also fill in values in `kep.yaml`) | ||
| - Feature gate name: | ||
| - Components depending on the feature gate: | ||
| - [x] Other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have an explicit mechanism for stating if a flag is alpha or not, there are a couple of approaches:
- Use
alphaprefix in the flag name, but I personally don't like that approach since it means we will have to change flag name eventually. - Force using env var, which allows this flag.
- Hiding the flag by default, similarly to how deprecated flags are hidden.
- Providing a description which is explicitly calling out it's alpha.
I'm personally leaning towards 3 or 4, and given this is an explicit opt-in (you need to place the flag when invoking kubectl command) I'm not worried that users will have issues with that.
This KEP proposes supporting a new flag `--subresource` to get, patch, edit and replace kubectl commands to fetch and update `status` and `scale` subresources.
8b65c13 to
6094074
Compare
|
/lgtm |
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: johnbelamaric, soltysh, ykakarap The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This KEP proposes adding a
--subresourceflag to kubectl to be able to fetch and update status and scale subresources.There is a POC implementation at : kubernetes/kubernetes#99556
For issue: #2590
xref kubernetes/kubectl#564 (comment), kubernetes/kubernetes#15858 (comment), kubernetes/kubernetes#67455
Follow up to kubernetes/kubernetes#60902, kubernetes/kubernetes#67454