Skip to content
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

KEP-2862: Fine-grained Kubelet API Authorization #4760

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vinayakankugoyal
Copy link
Contributor

  • One-line PR description: Adding a new KEP
  • Other comments:

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 12, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: vinayakankugoyal
Once this PR has been reviewed and has the lgtm label, please assign mikedanese for approval. For more information see the Kubernetes Code Review Process.

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 k8s-ci-robot added kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory sig/auth Categorizes an issue or PR as relevant to SIG Auth. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 12, 2024
@vinayakankugoyal
Copy link
Contributor Author

/cc @tallclair

@vinayakankugoyal vinayakankugoyal marked this pull request as draft July 17, 2024 23:21
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 17, 2024
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 19, 2024
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jul 19, 2024
@vinayakankugoyal vinayakankugoyal marked this pull request as ready for review July 24, 2024 17:26
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 24, 2024
@k8s-ci-robot k8s-ci-robot requested a review from enj July 24, 2024 17:26
Comment on lines +176 to +179
We propose a change to the Kubelet API authorization to provide more
fine-grained control. Currently, the API uses a coarse authorization scheme,
where actions like reading health status and the ability to exec into a pod
require the same permission.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AIUI, this is a primarily change to the Node API. Does that sound right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a change to the kubelet API. So agents (think logging and monitoring) that interact with the kubelet directly.

Comment on lines +206 to +207
- Introduce new subresources for `/healthz` and `/pods/` kubelet endpoints,
allowing for more granular authorization.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this right?

Suggested change
- Introduce new subresources for `/healthz` and `/pods/` kubelet endpoints,
allowing for more granular authorization.
- Introduce new subresources for a Node, `healthz` and `pods`, that are proxied to the kubelet endpoints
`/healthz` and `/pods/` respectively. Making this change allowsfor more granular authorization.

keps/sig-auth/2862-fine-grained-kubelet-authz/README.md Outdated Show resolved Hide resolved
keps/sig-auth/2862-fine-grained-kubelet-authz/README.md Outdated Show resolved Hide resolved
keps/sig-auth/2862-fine-grained-kubelet-authz/README.md Outdated Show resolved Hide resolved
Comment on lines +371 to +376
its user is bound to the `system:kubelet-api-admin` role. When the feature-gate
is enabled we will update the `ClusterRole` as follow:-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RBAC is an optional authz mode and we typically can't assume it's active in a cluster. Of course, nearly all clusters do enable RBAC. Anyway:

Suggested change
its user is bound to the `system:kubelet-api-admin` role. When the feature-gate
is enabled we will update the `ClusterRole` as follow:-
in a cluster with RBAC enabled, then its user is mapped to the `system:kubelet-api-admin`
ClusterRole.
For a cluster with the `KubeletFineGrainedAuthz` feature gate enabled, the
`system:kubelet-api-admin` ClusterRole could be changed to look like:

Comment on lines +392 to +401
- apiGroups:
- ""
resources:
- nodes
verbs:
- proxy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be allowing full access to proxy to all nodes. Is that what we want to demonstrate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This role already exists and has full access to proxy to all nodes. I just want to demonstrate the additional permissions we will add to this role.

keps/sig-auth/2862-fine-grained-kubelet-authz/README.md Outdated Show resolved Hide resolved
keps/sig-auth/2862-fine-grained-kubelet-authz/README.md Outdated Show resolved Hide resolved
keps/sig-auth/2862-fine-grained-kubelet-authz/README.md Outdated Show resolved Hide resolved
keps/sig-auth/2862-fine-grained-kubelet-authz/README.md Outdated Show resolved Hide resolved
keps/sig-auth/2862-fine-grained-kubelet-authz/README.md Outdated Show resolved Hide resolved
Comment on lines +864 to +885
<!--
Describe them, providing:
- API call type (e.g. PATCH pods)
- estimated throughput
- originating component(s) (e.g. Kubelet, Feature-X-controller)
Focusing mostly on:
- components listing and/or watching resources they didn't before
- API calls that may be triggered by changes of some Kubernetes resources
(e.g. update of object X triggers new updates of object Y)
- periodic API calls to reconcile state (e.g. periodic fetching state,
heartbeats, leader election, etc.)
-->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(optionally)

Suggested change
<!--
Describe them, providing:
- API call type (e.g. PATCH pods)
- estimated throughput
- originating component(s) (e.g. Kubelet, Feature-X-controller)
Focusing mostly on:
- components listing and/or watching resources they didn't before
- API calls that may be triggered by changes of some Kubernetes resources
(e.g. update of object X triggers new updates of object Y)
- periodic API calls to reconcile state (e.g. periodic fetching state,
heartbeats, leader election, etc.)
-->
For some requests, the API server performs an additional SubjectAccessReview (only when a check
for the `proxy` subresource wasn't authorized).

Signed-off-by: Vinayak Goyal <vinaygo@google.com>
@vinayakankugoyal
Copy link
Contributor Author

/assign @liggitt

### Notes

If this change were to be implemented as proposed, the `proxy` `subresource`
would still cover `/attach/`, `/exec/`, `/run/`, `/configz/`, `/debug/`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the motivation to keep /configz/under proxy? Reading config maybe useful for monitoring tools

Comment on lines +241 to +242
| /pods/ | proxy | proxy, pods |
| /runningpods/ | proxy | proxy, pods |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we documented those endpoints or have any stability guarantees. Introducing special permissions for those make those endpoints official.

We need to discuss in SIG Node forum whether we want to document those endpoints.

@dchen1107 @mrunalp

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are the other endpoints documented? Can you point me to those?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just to update this thread: we will have a discussion on SIG Node meeting next week

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shuaich
Copy link

shuaich commented Aug 14, 2024

Thank you @vinayakankugoyal for this proposal. LGTM.

@tallclair
Copy link
Member

/assign

@ffromani
Copy link
Contributor

/cc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory sig/auth Categorizes an issue or PR as relevant to SIG Auth. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

None yet

9 participants