Implement subresources in VWs - #4342
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
60af7fe to
3fc8c0e
Compare
3fc8c0e to
4aba907
Compare
|
/retest |
|
/retest One is #4343 |
|
/retest infra failure |
|
/retest |
|
Nice! /lgtm I'll leave approval for a bit if someone else wants to have a look. |
|
LGTM label has been added. DetailsGit tree hash: 0bb5af6988e649277b698d6e26a194d0f83dfff4 |
| // subresource status is implicitly granted with its parent resource. | ||
| // others must be claimed explicitly |
There was a problem hiding this comment.
Yes, we just never checked for subresource permissions because only implemented status so far.
Given kube also doesn't give implicit access to the status subresource - but requiring this now would break existing APIExport/-Bindings.
I wanted to bring this up in todays community meeting to see how we feel about this.
On one hand I'd rather we are exact, on the other I'm not sure how we could make this "nice" for end users.
E.g. we could gate the implicit status on a feature gate, but that isn't really nice.
We could just keep status being implicit for now and require it explicitly in the next API version.
But I'm not really a fan of either.
There was a problem hiding this comment.
Albeit not on paper, but the "spirit" of offering a service is for the consumer to give the spec, and provider to update the status - so I think it's assumed the provider needs access to that at all times, even when claiming. So if we're looking for an excuse to keep these perms implicit, I think this could be one :D but it does sound a bit weak.
There was a problem hiding this comment.
I mean yeah but for resources exported via an APIExport we are already implicitly claiming the resource and the subresources^^
But I get what you mean. Plus that subresources are only really interesting for update/patch, so at that point the consumer is already accepting mutations from the provider on the claimed resource - and that could include subresources.
| @@ -119,6 +124,50 @@ func provideDelegatingRestStorage(ctx context.Context, dynamicClusterClientFunc | |||
|
|
|||
| // TODO(sttts): add scale subresource | |||
There was a problem hiding this comment.
Is this TODO still relevant?
There was a problem hiding this comment.
Yes. CRDs can support the scale subresource, so technically a CRD could be exported via an APIExport that supports the scale subresource.
https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#scale-subresource
There was a problem hiding this comment.
But why is it different than status? Isn't this PR working for all subresources?
There was a problem hiding this comment.
Not all, but making it possible to handle subresources other than status with the changes to permission claims and handling it in authorization.
I can take a stab at implementing the scale subresource as well for completeness :D
I'm not sure if scale is actually different or if sttts just didn't bother with it at the time.
But I think there's more work down the line because I'm not sure how well this works for e.g. virtual resource. But I haven't used virtual resources at all so far so 🤷
There was a problem hiding this comment.
Done :D Scale subresource works!
|
New changes are detected. LGTM label has been removed. |
mjudeikis
left a comment
There was a problem hiding this comment.
Few other comments:
Two silent no-ops slip through admission:
an export claiming only serviceaccounts/token without claiming serviceaccounts → no API served, no error, no condition;
a CRD claim for a nonexistent subresource (cowboys/notreal + identityHash) → accepted, dead.
I have more things, but I think all and all we need better e2e:
- Non existing resource
- Only status claim
- Inherited status permissions (status does not have claims)
....
| - verbs | ||
| type: object | ||
| x-kubernetes-validations: | ||
| - message: subresource claims must use selector.matchAll |
There was a problem hiding this comment.
Does this meant that if I claim named resource virtualmachine I will get all other virtualmachines subresources?
There was a problem hiding this comment.
It just means that you can apply a selector on top of the selectors for the parent resource.
e.g. you have the virtualmachines resource with label my.exposed.resources=true and then you claim the subresource virtualmachines/ssh you cannot apply another label filter on top.
I had that implemented and I see some use for it (I mentioned that in the description) but I don't think that too many people will use it.
The story is basically "when you claim a subresource you must have access to its parent".
Hence the CEL validation that the selector must be matchall.
| ab.SetLabels(lbls) | ||
| } | ||
|
|
||
| // subresource claims have no selector, set a matchAll so users |
There was a problem hiding this comment.
This sets MatchAll = trueunconditionally, even when the user explicitly set matchLabels/matchExpressions on the subresource claim. ValidateAPIBindingPermissionClaims then rejects with "matchLabels cannot be used with matchAll" — for a matchAll the user never wrote, which will be very confusing to debug :)
There was a problem hiding this comment.
The user cannot set matchlabels/-expression; I added a CEL rule for that.
Maybe the rule doesn't hold in which case I have to fix that :D
91d92d3 to
db1f579
Compare
|
Lets discuss this |
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
127 because a resource can have up to 63 bytes per segment, so 63 for the resource, 63 for the subresource and 1 for the `/`. Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com> Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com> Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
Signed-off-by: Nelo-T. Wallus <red.brush9525@fastmail.com>
db1f579 to
8f53854
Compare
|
/retest |
|
@ntnn: The following test failed, say
DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
/retest |
Summary
Implements subresources in VWs, specifically the
TokenRequest.Went with RBAC style in the claims for less API changes and because it feels closer. I tested a separate
Subresoureas part of the claims but that didn't look quite right.I've been hacking on this on and off for two weeks.
I think its secure now because to access a subresource a) the claim for the subresource needs to be present and b) the parent resource needs to be claimed as well, so the usual gates apply.
subresource claims cannot have their own labels to prevent mismatching labels between parent and subresource (I could see the value of being able to distinguish that a provider has access to resource set A but only to subset B for accessing the subresource - but that feels like the edge case of an edge case).
What Type of PR Is This?
/kind feature
Related Issue(s)
Fixes #
Release Notes