Skip to content

Commit 81bf29f

Browse files
committed
KEP-3325: Self user attributes review API
Signed-off-by: m.nabokikh <[email protected]>
1 parent 6a4aadc commit 81bf29f

File tree

2 files changed

+327
-0
lines changed

2 files changed

+327
-0
lines changed
Lines changed: 299 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,299 @@
1+
# KEP-3325: Self user attributes review API
2+
3+
<!-- toc -->
4+
- [Release Signoff Checklist](#release-signoff-checklist)
5+
- [Summary](#summary)
6+
- [Motivation](#motivation)
7+
- [Goals](#goals)
8+
- [Non-Goals](#non-goals)
9+
- [Proposal](#proposal)
10+
- [Design Details](#design-details)
11+
- [Test Plan](#test-plan)
12+
- [Graduation Criteria](#graduation-criteria)
13+
- [Alpha](#alpha)
14+
- [Beta](#beta)
15+
- [GA](#ga)
16+
- [Production Readiness Review Questionnaire](#production-readiness-review-questionnaire)
17+
- [Feature Enablement and Rollback](#feature-enablement-and-rollback)
18+
- [Rollout, Upgrade and Rollback Planning](#rollout-upgrade-and-rollback-planning)
19+
- [Monitoring Requirements](#monitoring-requirements)
20+
- [Dependencies](#dependencies)
21+
- [Scalability](#scalability)
22+
- [Troubleshooting](#troubleshooting)
23+
- [Implementation History](#implementation-history)
24+
- [Alternatives](#alternatives)
25+
<!-- /toc -->
26+
27+
## Release Signoff Checklist
28+
29+
Items marked with (R) are required *prior to targeting to a milestone / release*.
30+
31+
- [ ] (R) Enhancement issue in release milestone, which links to KEP dir in [kubernetes/enhancements] (not the initial KEP PR)
32+
- [ ] (R) KEP approvers have approved the KEP status as `implementable`
33+
- [ ] (R) Design details are appropriately documented
34+
- [ ] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input (including test refactors)
35+
- [ ] e2e Tests for all Beta API Operations (endpoints)
36+
- [ ] (R) Ensure GA e2e tests for meet requirements for [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md)
37+
- [ ] (R) Minimum Two Week Window for GA e2e tests to prove flake free
38+
- [ ] (R) Graduation criteria is in place
39+
- [ ] (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)
40+
- [ ] (R) Production readiness review completed
41+
- [ ] (R) Production readiness review approved
42+
- [ ] "Implementation History" section is up-to-date for milestone
43+
- [ ] User-facing documentation has been created in [kubernetes/website], for publication to [kubernetes.io]
44+
- [ ] Supporting documentation—e.g., additional design documents, links to mailing list discussions/SIG meetings, relevant PRs/issues, release notes
45+
46+
<!--
47+
**Note:** This checklist is iterative and should be reviewed and updated every time this enhancement is being considered for a milestone.
48+
-->
49+
50+
[kubernetes.io]: https://kubernetes.io/
51+
[kubernetes/enhancements]: https://git.k8s.io/enhancements
52+
[kubernetes/kubernetes]: https://git.k8s.io/kubernetes
53+
[kubernetes/website]: https://git.k8s.io/website
54+
55+
## Summary
56+
57+
There is no resource which represents a user in Kubernetes. Instead, Kubernetes has authenticators to get user attributes from tokens or x509 certificates or by using the OIDC provider or receiving them from the external webhook. This KEP proposes adding a new API endpoint to see what attributes the current user has after the authentication.
58+
59+
## Motivation
60+
61+
Authentication is complicated, especially made by [proxy](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#authenticating-proxy) or [webhook](https://kubernetes.io/docs/reference/access-authn-authz/authentication/#webhook-token-authentication) authenticators or their combinations.
62+
It may be obscure which user attributes the user eventually gets after all that magic happened before authentication.
63+
The motivation for this KEP is to reduce obscurity and help users with debugging the authentication stack.
64+
65+
### Goals
66+
67+
- Add the API endpoint to get user attributes
68+
69+
### Non-Goals
70+
71+
- Add a corresponding kubectl command
72+
73+
## Proposal
74+
75+
Add a new API endpoint to the `authentication` group - `SelfUserAttributesReview`.
76+
The user will hip the endpoint after authentication happens, so all attributes will be available to return.
77+
78+
## Design Details
79+
80+
This design is inspired by the `*AccessReview` and `TokenReview` APIs.
81+
The endpoint has no input parameters or a `spec` field because only the authentication result is required.
82+
83+
The structure for building a request:
84+
```go
85+
type SelfUserAttributesReview struct {
86+
metav1.TypeMeta `json:",inline"`
87+
// Standard list metadata.
88+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
89+
// +optional
90+
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
91+
// Status is filled in by the server with the user attributes.
92+
Status SelfUserAttributesReviewStatus `json:"status,omitempty" protobuf:"bytes,2,opt,name=status"`
93+
}
94+
```
95+
96+
On receiving a request, the Kubernetes API server fills the status with the user attributes and returns it to the user.
97+
98+
```go
99+
type SelfUserAttributesReviewStatus struct {
100+
// User attributes of the current user.
101+
// +optional
102+
UserInfo UserInfo `json:"userInfo,omitempty" protobuf:"bytes,1,opt,name=userInfo"`
103+
}
104+
105+
type UserInfo struct {
106+
Name string `json:"name" protobuf:"bytes,1,opt,name=name"`
107+
UID string `json:"uid" protobuf:"bytes,2,opt,name=uid"`
108+
Groups []string `json:"groups" protobuf:"bytes,1,opt,name=groups"`
109+
Extra map[string][]string `json:"extra" protobuf:"bytes,1,opt,name=extra"`
110+
}
111+
```
112+
113+
User attributes are known at the moment of accessing the rest API endpoint and can be extracted from the request context.
114+
115+
### Test Plan
116+
117+
Unit tests covering:
118+
119+
1. Request returns all user attributes
120+
2. Request returns some user attributes
121+
3. Request with a status returns overridden fields
122+
123+
Integration test covering:
124+
125+
1. Successful authentication through a simple authenticator, e.g., token or certificate authenticator
126+
2. Successful authentication through a complicated authenticator, e.g., webhook or authentication proxy authenticator
127+
3. Failed authentication
128+
129+
### Graduation Criteria
130+
131+
#### Alpha
132+
133+
- Feature implemented behind a feature flag
134+
- Initial unit and integration tests completed and enabled
135+
136+
#### Beta
137+
138+
- Gather feedback from users
139+
140+
#### GA
141+
142+
- Corresponding kubectl command implemented
143+
144+
NOTE: Should not be a part pf [conformance tests](https://git.k8s.io/community/contributors/devel/sig-architecture/conformance-tests.md).
145+
146+
## Production Readiness Review Questionnaire
147+
148+
### Feature Enablement and Rollback
149+
150+
###### How can this feature be enabled / disabled in a live cluster?
151+
152+
<!--
153+
Pick one of these and delete the rest.
154+
-->
155+
156+
- Feature gate
157+
- Feature gate name: `SelfUserAttributesReview`
158+
- Components depending on the feature gate:
159+
- kube-apiserver
160+
161+
```go
162+
FeatureSpec{
163+
Default: false,
164+
LockToDefault: false,
165+
PreRelease: featuregate.Alpha,
166+
}
167+
```
168+
169+
###### Does enabling the feature change any default behavior?
170+
171+
It only adds new behavior and does not affect other pars of the Kubernetes.
172+
173+
###### Can the feature be disabled once it has been enabled (i.e. can we roll back the enablement)?
174+
175+
Yes.
176+
177+
###### What happens if we reenable the feature if it was previously rolled back?
178+
179+
It is possible to toggle this feature any number of times.
180+
181+
###### Are there any tests for feature enablement/disablement?
182+
183+
Does not require special testing frameworks.
184+
185+
### Rollout, Upgrade and Rollback Planning
186+
187+
###### How can a rollout or rollback fail? Can it impact already running workloads?
188+
189+
Enabling the feature does not affect any workloads.
190+
191+
###### What specific metrics should inform a rollback?
192+
193+
Specific metrics are not required for the monitoring of this feature.
194+
195+
###### Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?
196+
197+
<!--
198+
Describe manual testing that was done and the outcomes.
199+
Longer term, we may want to require automated upgrade/rollback tests, but we
200+
are missing a bunch of machinery and tooling and can't do that now.
201+
-->
202+
203+
###### Is the rollout accompanied by any deprecations and/or removals of features, APIs, fields of API types, flags, etc.?
204+
205+
Yes.
206+
207+
### Monitoring Requirements
208+
209+
###### How can an operator determine if the feature is in use by workloads?
210+
211+
It is possible to see the rate of requests to the REST API endpoint.
212+
213+
###### How can someone using this feature know that it is working for their instance?
214+
215+
It will be possible to make a request to the REST API endpoint.
216+
217+
###### What are the reasonable SLOs (Service Level Objectives) for the enhancement?
218+
219+
The feature utilizes core mechanisms of the Kubernetes API server, so the maximum possible SLO is applicable.
220+
221+
###### What are the SLIs (Service Level Indicators) an operator can use to determine the health of the service?
222+
223+
The apiserver_request_* metrics family is helpful to be aware of how many requests to the endpoint are in your cluster and how many of them failed.
224+
```
225+
{__name__=~"apiserver_request_.*", group="authentication.k8s.io", resource="selfuserattributesreviews"}
226+
```
227+
228+
###### Are there any missing metrics that would be useful to have to improve observability of this feature?
229+
230+
All useful metrics are already present. This feature only requires metrics linked to authentication process.
231+
232+
### Dependencies
233+
234+
###### Does this feature depend on any specific services running in the cluster?
235+
236+
It depends only on authentication and how this process is tuned in the current Kubernetes cluster.
237+
238+
### Scalability
239+
240+
###### Will enabling / using this feature result in any new API calls?
241+
242+
No.
243+
244+
###### Will enabling / using this feature result in introducing new API types?
245+
246+
```
247+
Group: authentication
248+
Kind: SelfUserAttributesReview
249+
```
250+
251+
###### Will enabling / using this feature result in any new calls to the cloud provider?
252+
253+
No.
254+
255+
###### Will enabling / using this feature result in increasing size or count of the existing API objects?
256+
257+
No.
258+
259+
###### Will enabling / using this feature result in increasing time taken by any operations covered by existing SLIs/SLOs?
260+
261+
No.
262+
263+
###### Will enabling / using this feature result in non-negligible increase of resource usage (CPU, RAM, disk, IO, ...) in any components?
264+
265+
No.
266+
267+
### Troubleshooting
268+
269+
###### How does this feature react if the API server and/or etcd is unavailable?
270+
271+
The authentication error will be returned.
272+
273+
###### What are other known failure modes?
274+
275+
The only possible errors are authentication errors.
276+
277+
###### What steps should be taken if SLOs are not being met to determine the problem?
278+
279+
No steps required.
280+
281+
## Implementation History
282+
283+
<!--
284+
Major milestones in the lifecycle of a KEP should be tracked in this section.
285+
Major milestones might include:
286+
- the `Summary` and `Motivation` sections being merged, signaling SIG acceptance
287+
- the `Proposal` section being merged, signaling agreement on a proposed design
288+
- the date implementation started
289+
- the first Kubernetes release where an initial version of the KEP was available
290+
- the version of Kubernetes where the KEP graduated to general availability
291+
- when the KEP was retired or superseded
292+
-->
293+
294+
## Alternatives
295+
296+
This feature can be implemented by delegating some requests to the external API server.
297+
A good example of this schema working is [vmware-tanzu/pinniped](https://github.com/vmware-tanzu/pinniped) and their [`whoami`](https://github.com/vmware-tanzu/pinniped/blob/main/apis/concierge/identity/types_whoami.go.tmpl) API.
298+
299+
However, it is complicated to maintain an additional API server for this case, and it integrates poorly with tooling, e.g., client-go, kubectl.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: 3325-self-user-attributes-review-api
2+
title: Review attibutes of a current user
3+
kep-number: "3325"
4+
authors:
5+
- "@nabokihms"
6+
owning-sig: sig-auth
7+
participating-sigs:
8+
- sig-auth
9+
reviewers:
10+
- "@enj"
11+
- TBD
12+
approvers:
13+
- TBD
14+
prr-approvers: []
15+
creation-date: "2022-05-30"
16+
status: provisional
17+
stage: alpha
18+
latest-milestone: "v1.25"
19+
milestone:
20+
alpha: "v1.25"
21+
beta: "v1.26"
22+
stable: "v1.27"
23+
feature-gates:
24+
- name: SelfUserAttributesReview
25+
components:
26+
- kube-apiserver
27+
disable-supported: false
28+
metrics: []

0 commit comments

Comments
 (0)