enhancements icon indicating copy to clipboard operation
enhancements copied to clipboard

KEP-3285: subresource for metadata.finalizers

Open mkimuram opened this issue 3 years ago • 27 comments

  • One-line PR description: subresource finalizers
  • Issue link: https://github.com/kubernetes/enhancements/issues/3285
  • Other comments:

mkimuram avatar Apr 29 '22 19:04 mkimuram

/assign @lavalamp @deads2k

wojtek-t avatar May 02 '22 07:05 wojtek-t

@lavalamp @deads2k Could you give feedback on this KEP?

mkimuram avatar Jun 03 '22 19:06 mkimuram

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mkimuram To complete the pull request process, please ask for approval from deads2k after the PR has been reviewed.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment Approvers can cancel approval by writing /approve cancel in a comment

k8s-ci-robot avatar Jun 11 '22 11:06 k8s-ci-robot

@thockin Thank you for your review. I've update this KEP to address your comments. I don't think that we can make it for v1.25, so please review it when you have enough bandwidth.

(I would like to make this KEP detailed enough not to make this KEP a blocker for lien KEP).

mkimuram avatar Jun 15 '22 01:06 mkimuram

As we think about this, another good subresource could be /status/conditions

thockin avatar Jun 20 '22 20:06 thockin

It almost looks like we're creeping into per-field RBAC. If we step back and think about this in that frame, does it change how we implement it? Would you still want to implement this as a bunch of subresources, or is there a better way?

johnbelamaric avatar Jun 20 '22 23:06 johnbelamaric

It almost looks like we're creeping into per-field RBAC. If we step back and think about this in that frame, does it change how we implement it? Would you still want to implement this as a bunch of subresources, or is there a better way?

I guess that would only get us permissions but not independent PUTs and DELETEs, so maybe it's insufficient anyway.

johnbelamaric avatar Jun 20 '22 23:06 johnbelamaric

I think subresources is the path to more granular access, but obviously not every field. This proposal is really about providing better control of permissions for things that are commonly used to implement controllers, especially non-core things.

For comparison, I would probably NOT endorse a sub-resource for individual service fields.

One could argue that we could have a single /metadata subresource which covers all of these, but it seems valuable to go for granularity since we know that there's a difference between "I can add a finalizer" and "I can change your labels". It would be nice to go EVEN finer - e.g. a given pricipal can add/remove finalizers with a specific prefix, but that seems like it would require even more thinking and deeper changes. Anyone feel up for it? :D

thockin avatar Jun 21 '22 19:06 thockin

/lgtm

thockin avatar Jun 23 '22 15:06 thockin

PRR is fine, needs SIG approval.

johnbelamaric avatar Jun 23 '22 20:06 johnbelamaric

I think we can't approve this now, this was @deads2k's ask and I'm not sure this is what he was hoping to get. Since he hasn't already approved, I'll say what I think:

If it were just this in isolation, then a subresource seems right, but it's not, it's N metadata fields, certainly we need this for labels, annotations, ownerReferences, liens if we do that... that turns into a lot of subresources and a lot of custom ~verbs~permissions, and suddenly it's no longer true that you only have to know a few things to be a k8s api client.

I would like to see a comparison with another approach, e.g. extending RBAC to limit to specific fields only, before settling on this.

Really sorry for the late time in the cycle at which I was able to review.

lavalamp avatar Jun 23 '22 22:06 lavalamp

What do you mean "custom verbs" ? Obviously it has client-lib expansion, but the verbs are common?

thockin avatar Jun 23 '22 23:06 thockin

Meant permissions (RBAC verb), sorry, edited.

lavalamp avatar Jun 23 '22 23:06 lavalamp

I would like to see a comparison with another approach, e.g. extending RBAC to limit to specific fields only, before settling on this.

It seems an interesting idea. If we can set a separate RBAC without adding endpoints, it would be nice. I agree with continuing discussion by comparing another approaches like it (And thanks to @thockin and @apelisse, subresource approach become a bit more detailed, which seems a good big step to solve the issue in this release).

mkimuram avatar Jun 23 '22 23:06 mkimuram

When/where can we continue this discussion? I'm eager to see us do better on controller permissions and this (abstract field-level control) seems like a big step forward.

Should we put it on sig-auth or sig-api-machinery sometime in the not-too-distant future? If so, please tell me when and I will be there :)

thockin avatar Jun 23 '22 23:06 thockin

My vague idea is to add to roles/cluster roles optional allow and deny field lists, so you can give permissions specifically to a given fieldset, or on all fields NOT in that fieldset. The system would find all roles you match an union the permitted fields to figure out what you're allowed to set. This would really help some people trying to enforce certain policies, since many policies can be enforced by a special permission being needed for a certain field.

SSA has a relatively compact field specification format we could use...

I don't have time right now to expand this into a proper design, so hopefully this vague paragraph inspires someone.

SIG Auth & SIG API Machinery are the places to debate this. I suspect field-level control is considered either very hard or an anti-goal right now so it may be difficult, but I think it would help every field all at once instead of us making a KEP + subresource per important field.

lavalamp avatar Jun 23 '22 23:06 lavalamp

Also I'm really sorry again I didn't find time to read this 3 weeks ago.

lavalamp avatar Jun 23 '22 23:06 lavalamp

I would like to see a comparison with another approach, e.g. extending RBAC to limit to specific fields only, before settling on this.

This was my initial take too. But it's more than just field access. We need to be able to independently append to a list and remove from the list. That is, multiple actors need to be able to modify the same field without clobbering each other. Being able to do PUT and DELETE independently on specific values in the list (as if they were real resources) enables that naturally. Just allowing write access to the field doesn't.

johnbelamaric avatar Jun 24 '22 00:06 johnbelamaric

Being able to do PUT and DELETE independently on specific values in the list (as if they were real resources)

Nothing in our API works like that. Clients to do that would be very unlike existing clients and that is bad for supporting N languages.

multiple actors need to be able to modify the same field without clobbering each other

SSA fixes this! (...we just need a syntax for representing removing an item you don't own. but you can do that with one of the existing patch formats in a pinch.)

We do not currently enforce certain users only touch "their" values in certain fields in the API, that's the domain of policy e.g. gatekeeper. We would not start doing that with this proposal or any other similar proposal.

lavalamp avatar Jun 24 '22 04:06 lavalamp

A minor comment: shouldn't this be titled "finalizers subresource" instead of "subresource finalizers"? I always thought this refers to finalizing subresources (which doesn't make sense though) before reading the KEP.

SOF3 avatar Aug 07 '22 02:08 SOF3

I would like to see a comparison with another approach, e.g. extending RBAC to limit to specific fields only, before settling on this.

BTW, a discussion item is now on the SIG API Machinery agenda for next meeting (next Wednesday) and also SIG Auth's agenda (the following Wednesday). Hopefully we can get a clear answer.

lavalamp avatar Sep 15 '22 18:09 lavalamp

I have retitled this.

What are next steps on the scoped-authz doc?

thockin avatar Sep 22 '22 00:09 thockin

What are next steps on the scoped-authz doc?

SIG Auth road show next week. Then bigger write up of (probably) design 4 as a KEP

lavalamp avatar Sep 22 '22 00:09 lavalamp

I am not sure I agree about nouns. I always read "scale" as a verb. I think of subresources as either literally a sub-section of the type (status) or an abstract polymorphic method. "Scale this resource".

So my lean is towards "finalize". But I could be happy either way. Since scale was ambiguous, this becomes our precedent setter :)

On Sat, Jun 11, 2022, 4:53 AM Tim Bannister @.***> wrote:

@.**** requested changes on this pull request.

In keps/sig-api-machinery/3285-subresource-finalizers/README.md https://github.com/kubernetes/enhancements/pull/3286#discussion_r895015506 :

+Currently, finalizers field isn't subresourced, therefore RBAC for the field can only be set through the one for its entire resource. +On the other hand, some controllers only need to update finalizers field and some of its subresources, and don't need to update its entire resource. +To implement least privilege for such controllers, there should be a way to only allow updating finalizers.

+### Goals + +- Provide a way to set a different RBAC to finalizers from its entire resource + +### Non-Goals + +- Provide a way to set a different RBAC to other than finalizers from its entire resource +- Provide a way to allow updating its entire resource but disallow updating finalizers field + +## Proposal + +A new endpoint finalize is added as an alternative way to access to finalizers field and allow setting a separate RBAC to the endpoint.

Resources and subresources are usually nouns or noun-like. This should be finalizers not finalize.

Compare status, tokenrequest, scale: all noun-like.

— Reply to this email directly, view it on GitHub https://github.com/kubernetes/enhancements/pull/3286#pullrequestreview-1003454053, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKWAVHHAVWBU2NIIU4MM43VOR4Z7ANCNFSM5UW7NHQA . You are receiving this because you were assigned.Message ID: @.***>

thockin avatar Oct 11 '22 08:10 thockin

If status is a subresource, then it's surely a noun subresource? Other examples are tokens for ServiceAccount (not createtoken). You can ask the API server to create, update or delete a subresource. That ought to include a (list of) finalizers.

I'm sure that the likes of Tim Berners-Lee and Roy Fielding would be thinking of nouns here, and I think we should too.

sftim avatar Oct 11 '22 09:10 sftim

Since it returns a Scale object, I thought of it as a noun. Surveying what we currently have:

verbs:

  • */proxy
  • namespaces/finalize
  • pods/attach
  • pods/exec
  • pods/portforward

nouns:

  • */status
  • pods/log
  • pods/ephemeralcontainers
  • pods/eviction (not pods/evict)
  • pods/binding (not pods/bind)
  • serviceaccounts/token (not createtoken)
  • certificatesigningrequests/approval (not certificatesigningrequests/approve)

ambiguous:

  • */scale

Framing resources/subresources as nouns which are acted on by verbs makes more sense to me and matches how the authz layer treats requests.

liggitt avatar Oct 11 '22 13:10 liggitt

The model conformant subresources are supposed to be nouns. namespaces/finalize was named incorrectly.

lavalamp avatar Oct 11 '22 20:10 lavalamp

@lavalamp - do I understand correctly, that the current plan of record is something along the lines with https://github.com/kubernetes/enhancements/pull/3617 and we decided that going with subresources is not the right way to go (as also mentioned in that KEP)?

If so, should we close this KEP then?

wojtek-t avatar Jan 05 '23 13:01 wojtek-t

@wojtek-t Yeah I think I have directional approval from both sig auth and api machinery for that. But I don't have people signed up to finish & implement it.

lavalamp avatar Jan 05 '23 20:01 lavalamp

Yeah I think I have directional approval from both sig auth and api machinery for that. But I don't have people signed up to finish & implement it.

I understand that, but that also means we won't go with this proposal because we believe that subresources aren't the right path no matter what. So I will just go ahead and close this KEP.

wojtek-t avatar Jan 09 '23 07:01 wojtek-t