@@ -195,9 +195,13 @@ impersonate.
195
195
Introduce verbs `impersonate:user-info`, `impersonate:serviceaccount` and `impersonate:scheduled-node` :
196
196
- ` impersonate:user-info` limits the impersonator to impersonate users with
197
197
certain names/groups/userextras. The resources must be `users`/`groups`/`userextras`/`uids`.
198
- The resource names must be user names, group names or values in the user extras accoringly.
198
+ and the user must not be a node (username with a prefix of `system:nodes`)
199
+ The resource names must be usernames, group names or values in the user extras accoringly.
199
200
- ` impersonate:serviceaccount` that limits the impersonator to impersonate the serviceaccount with
200
201
the certain name/namespace. The resources must be `serviceaccounts`.
202
+ - ` impersonate:node` that limits the impersonator to impersonate the node only. The resource
203
+ must be `nodes`, and the resourceName should be the name of the node. The impersonator must have this
204
+ verb to impersonate a node.
201
205
- ` impersonate:scheduled-node` that limits the impersonator to impersonate the node the
202
206
impersonator is running on. The resources must be `nodes`.
203
207
@@ -267,8 +271,9 @@ subjects:
267
271
These permissions define : " The impersonator can impersonate a user with the name of
268
272
someUser to list and watch pods in the default namespace."
269
273
270
- When receiving an impersonation request to list pods from the user `impersonator` with the header of
271
- `Impersonate-User:someUser`, the apiserver :
274
+ # ## Subject Access Review Details
275
+ When receiving an impersonation request to list pods cluster-wid from the user `impersonator`
276
+ with the header of `Impersonate-User:someUser`, the apiserver :
272
277
- Verifies if the impersonator has the permission to impersonate with the scope of the user.
273
278
A subjectaccessreview is sent to the authorizer :
274
279
` ` ` yaml
@@ -384,13 +389,14 @@ subjects:
384
389
385
390
# ### Story 2
386
391
387
- As a controller, I am working as a deputy, receiving any user's request to access virtual machine console.
392
+ As a controller, I am working as a deputy, receiving any user's request to access virtual machine console
393
+ in the `default` namespace.
388
394
389
395
` ` ` yaml
390
396
apiVersion: rbac.authorization.k8s.io/v1
391
397
kind: ClusterRole
392
398
metadata:
393
- name: impersonate-user
399
+ name: impersonate:vm:console
394
400
rules:
395
401
- apiGroups:
396
402
- authentications.k8s.io
@@ -402,11 +408,11 @@ rules:
402
408
apiVersion: rbac.authorization.k8s.io/v1
403
409
kind: ClusterRoleBinding
404
410
metadata:
405
- name: impersonate-user
411
+ name: impersonate:vm:console
406
412
roleRef:
407
413
apiGroup: rbac.authorization.k8s.io
408
414
kind: ClusterRole
409
- name: impersonate-user
415
+ name: impersonate:vm:console
410
416
subjects:
411
417
- kind: ServiceAccount
412
418
name: deputy
@@ -460,6 +466,17 @@ used by other component, and been set in Role/ClusterRole. Since `impersonate`
460
466
permission is also required for impersonator, the component will not get more
461
467
power when permssion of `impersonate-on:` is given.
462
468
469
+ # ### High request volume leads to high load on authorization chain.
470
+
471
+ For the scheduled node case, it is possible that a high request volume node
472
+ agent could be constantly performing impersonated requests, each of which would
473
+ add two extra authorization checks. This could put load on the authorization
474
+ chain. We could cache the check results with a certain time period to mitigate
475
+ it which will requires more complicated cache design :
476
+ - the key should include resources/actions/subjects
477
+ - the value should be marked as invalidated for a certain period.
478
+ This part of design and implementation will be considered in beta phase.
479
+
463
480
# # Design Details
464
481
465
482
<!--
@@ -558,16 +575,33 @@ spec:
558
575
user: impersonator
559
576
` ` `
560
577
561
- # ## Verb `impersonate:scheduled-node`
578
+ # ## Verb `impersonate:node` and `impersonate: scheduled-node`
562
579
563
- This is a special verb to check when two conditions are met :
580
+ When the request has the header of `Impersonate-User`, and the value has the prefix of `system:nodes`,
581
+ this verb is checked instead of `impersonate:user-info`. The subjectaccessreview below will be sent
582
+ to the authorizer :
583
+ ` ` ` yaml
584
+ apiVersion: authorization.k8s.io/v1
585
+ kind: SubjectAccessReview
586
+ spec:
587
+ resourceAttributes:
588
+ group: authentications.k8s.io
589
+ resource: nodes
590
+ name: someNode
591
+ verb: impersonate:nodes
592
+ user: impersonator
593
+ ` ` `
594
+
595
+ `impersonate:scheduled-node` is a special verb to check when two conditions are met :
564
596
1. The impersonator is impersonating a node by setting the header `Impersonate-User` and the value has a prefix
565
597
of `system:node:` on the request.
566
598
2. The user info of the impersonator has an extra with key `authentication.kubernetes.io/node-name`, and the value
567
599
should be the same as the value in the request header of `Impersonate-User` after removing prefix `system:node:`.
568
600
It indicates that the impersonator is running on the same node it is impersonating.
569
601
570
- If the two conditions are both met, the following subjectaccessreview will be sent to the authorizer :
602
+ The flow for checking these two verbs will be as following :
603
+ 1. If condition 1 is not met, verb `impersonate:user-info` will be checked instead.
604
+ 2. If both conditions are met, the verb `impersonate:scheduled-node` will be checked at first :
571
605
` ` ` yaml
572
606
apiVersion: authorization.k8s.io/v1
573
607
kind: SubjectAccessReview
@@ -578,27 +612,27 @@ spec:
578
612
verb: impersonate:scheduled-node
579
613
user: impersonator
580
614
` ` `
581
- If one of the conditions is not met, verb `impersonate:scheduled-node` will not be checked and verb
582
- ` impersonate:user-info` will be checked instead. For instance, if condition 2 is not met, the following
583
- subjectaccessreview will be sent.
615
+ 3. If check in step 2 is not passed, or only condition 1 is met, the verb impersonate:node will be checked :
584
616
` ` ` yaml
585
617
apiVersion: authorization.k8s.io/v1
586
618
kind: SubjectAccessReview
587
619
spec:
588
620
resourceAttributes:
589
621
group: authentications.k8s.io
590
- resource: users
591
- name: system:node: node1
592
- verb: impersonate:user-info
622
+ resource: nodes
623
+ name: node1
624
+ verb: impersonate:node
593
625
user: impersonator
594
626
` ` `
595
627
596
628
# ## Auditing
597
629
598
- An audit event is recorded already for any allowed impersonation request. To record the reason why the impersonation
599
- is allowed, an annotation `allowed-impersonation-verbs` will be added. The value will be the list of impersonation
600
- related verbs checked. For example, `allowed-impersonation-verbs : impersonate:scheduled-node,impersonate-on:list`
601
- indicates that the impersonation request is allowed because it impersonates a scheduled node on list action.
630
+ Audit events already contain the `impersonatedUser` field to denote if impersonation was used.
631
+ To record the reason why the impersonation is allowed, an annotation `allowed-impersonation-verbs` will
632
+ be added. The value will be the impersonation related verbs. For example,
633
+ `allowed-impersonation-verbs : impersonate:scheduled-node` indicates that the impersonation request is
634
+ allowed because it impersonates a scheduled node. The specific action such as `list` or `get`
635
+ will not be included in the value given it can be inferred from the request itself.
602
636
603
637
# ## Test Plan
604
638
@@ -1144,6 +1178,8 @@ This through this both in small and large cases, again with respect to the
1144
1178
[supported limits] : https://git.k8s.io/community//sig-scalability/configs-and-limits/thresholds.md
1145
1179
-->
1146
1180
1181
+ NA
1182
+
1147
1183
# ##### Can enabling / using this feature result in resource exhaustion of some node resources (PIDs, sockets, inodes, etc.)?
1148
1184
1149
1185
<!--
@@ -1187,6 +1223,12 @@ For each of them, fill in the following information by copying the below templat
1187
1223
Not required until feature graduated to beta.
1188
1224
- Testing : Are there any tests for failure mode? If not, describe why.
1189
1225
-->
1226
+ - Impersonation permission is set but request is disallowed with external authorizer.
1227
+ - Detection : metrics of `authorization success` will show the unauthorized requests
1228
+ - Mitigations : Stop sending the impersonation requests
1229
+ - Diagnostics : APIServer log will show the reason why the request is unauthorized.
1230
+ - Testing : There is no general test for that, user using external authorizer need to
1231
+ test for the specific authorizer.
1190
1232
1191
1233
# ##### What steps should be taken if SLOs are not being met to determine the problem?
1192
1234
@@ -1203,6 +1245,8 @@ Major milestones might include:
1203
1245
- when the KEP was retired or superseded
1204
1246
-->
1205
1247
1248
+ - Kubernetes 1.34 : Alpha version of the KEP.
1249
+
1206
1250
# # Drawbacks
1207
1251
1208
1252
- Several additional authorization checks are added introducing some overhead.
0 commit comments