@@ -122,6 +122,7 @@ tags, and then generate with `hack/update-toc.sh`.
122
122
- [ Setting a special APIGroup suffix instead of special verb] ( #setting-a-special-apigroup-suffix-instead-of-special-verb )
123
123
- [ Check permission intersection of impersonator and target user] ( #check-permission-intersection-of-impersonator-and-target-user )
124
124
- [ Expand RBAC/SAR] ( #expand-rbacsar )
125
+ - [ Conditional Authorization] ( #conditional-authorization )
125
126
- [ Infrastructure Needed (Optional)] ( #infrastructure-needed-optional )
126
127
<!-- /toc -->
127
128
@@ -171,7 +172,8 @@ Items marked with (R) are required *prior to targeting to a milestone / release*
171
172
172
173
This is to add additional access control over the existing impersonation action. An impersonator
173
174
who impersonates another user is required to have the additional permissions to impersonate on
174
- certain group resources and verbs.
175
+ certain group resources and verbs. In order for the request to succeed, the impersonated principal
176
+ must have permission to perform the request, just like before.
175
177
176
178
## Motivation
177
179
Today an impersonator can impersonate another user if the impersonator has the permission of
@@ -222,16 +224,31 @@ and the user must not be a node (username with a prefix of `system:node:`) and t
222
224
not be a service account (username with a prefix of `system:serviceaccount:`)
223
225
The resource names must be usernames, group names or values in the user extras accoringly.
224
226
- ` impersonate:serviceaccount` that limits the impersonator to impersonate the serviceaccount with
225
- the certain name/namespace. The resources must be `serviceaccounts`.
227
+ the certain name/namespace. The resource must be `serviceaccounts`.
226
228
- ` impersonate:node` that limits the impersonator to impersonate the node only. The resource
227
229
must be `nodes`, and the resourceName should be the name of the node. The impersonator must have this
228
230
verb to impersonate a node.
229
231
- ` impersonate:scheduled-node` that limits the impersonator to impersonate the node the
230
- impersonator is running on. The resources must be `nodes`.
232
+ impersonator is running on. The resources must be `nodes`. For a controller impersonating the node
233
+ that it is running on, it will need to know the node name obtained via downward API :
234
+ ` ` ` yaml
235
+ env:
236
+ - name: MY_NODE_NAME
237
+ valueFrom:
238
+ fieldRef:
239
+ fieldPath: spec.nodeName
240
+ ` ` `
241
+ and then set in the kubeconfig :
242
+ ` ` ` go
243
+ kubeConfig, _ := clientcmd.BuildConfigFromFlags("", "")
244
+ kubeConfig.Impersonate = rest.ImpersonationConfig{
245
+ UserName: "system:node:" + os.Getenv("MY_NODE_NAME"),
246
+ }
247
+ ` ` `
231
248
232
- For clusters that use RBAC authz mode, two permissions will be required for impersonation. For example:
233
- to express " system:serviceaccount:default:default can impersonate a user named someUser solely to list
234
- and watch pods in the default namespace."
249
+ Two permissions will be required for impersonation. An example of how to express
250
+ " ` system:serviceaccount:default:default` can impersonate a user named someUser solely to list
251
+ and watch pods in the default namespace." using Kubernetes RBAC:
235
252
1. The permission to constrained impersonate a certain user. This is a cluster scoped permission.
236
253
` ` ` yaml
237
254
apiVersion: rbac.authorization.k8s.io/v1
@@ -240,7 +257,7 @@ metadata:
240
257
name: constrained-impersonate-only-someUser
241
258
rules:
242
259
- apiGroups:
243
- - authentications .k8s.io
260
+ - authentication .k8s.io
244
261
resources:
245
262
- users # allowed resources are users/groups/userextras/uids
246
263
resourceNames:
@@ -255,7 +272,7 @@ metadata:
255
272
roleRef:
256
273
apiGroup: rbac.authorization.k8s.io
257
274
kind: ClusterRole
258
- name: impersonate
275
+ name: constrained- impersonate-only-someUser
259
276
subjects:
260
277
- kind: ServiceAccount
261
278
name: default
@@ -267,7 +284,7 @@ cluster scoped or namespace scoped.
267
284
apiVersion: rbac.authorization.k8s.io/v1
268
285
kind: Role
269
286
metadata:
270
- name: impersonate-action
287
+ name: impersonate-allow-only-listwatch-pods
271
288
namespace: default
272
289
rules:
273
290
- apiGroups:
@@ -281,12 +298,12 @@ rules:
281
298
apiVersion: rbac.authorization.k8s.io/v1
282
299
kind: RoleBinding
283
300
metadata:
284
- name: impersonate
301
+ name: impersonate-allow-only-listwatch-pods
285
302
namespace: default
286
303
roleRef:
287
304
apiGroup: rbac.authorization.k8s.io
288
305
kind: Role
289
- name: impersonate-action
306
+ name: impersonate-allow-only-listwatch-pods
290
307
subjects:
291
308
- kind: ServiceAccount
292
309
name: default
@@ -306,7 +323,7 @@ apiVersion: authorization.k8s.io/v1
306
323
kind: SubjectAccessReview
307
324
spec:
308
325
resourceAttributes:
309
- group: authentications .k8s.io
326
+ group: authentication .k8s.io
310
327
resource: users
311
328
name: someUser
312
329
verb: impersonate:user-info
@@ -433,10 +450,10 @@ in the `default` namespace.
433
450
apiVersion: rbac.authorization.k8s.io/v1
434
451
kind: ClusterRole
435
452
metadata:
436
- name: impersonate:vm:console
453
+ name: impersonate-user :vm:console
437
454
rules:
438
455
- apiGroups:
439
- - authentications .k8s.io
456
+ - authentication .k8s.io
440
457
resources:
441
458
- users
442
459
verbs:
@@ -445,11 +462,11 @@ rules:
445
462
apiVersion: rbac.authorization.k8s.io/v1
446
463
kind: ClusterRoleBinding
447
464
metadata:
448
- name: impersonate:vm:console
465
+ name: impersonate-user :vm:console
449
466
roleRef:
450
467
apiGroup: rbac.authorization.k8s.io
451
468
kind: ClusterRole
452
- name: impersonate:vm:console
469
+ name: impersonate-user :vm:console
453
470
subjects:
454
471
- kind: ServiceAccount
455
472
name: deputy
@@ -458,7 +475,7 @@ subjects:
458
475
apiVersion: rbac.authorization.k8s.io/v1
459
476
kind: Role
460
477
metadata:
461
- name: impersonate:vm:console
478
+ name: impersonate:vm:console:get
462
479
namespace: default
463
480
rules:
464
481
- apiGroups:
@@ -471,12 +488,12 @@ rules:
471
488
apiVersion: rbac.authorization.k8s.io/v1
472
489
kind: RoleBinding
473
490
metadata:
474
- name: impersonate-user
491
+ name: impersonate:vm:console:get
475
492
namespace: default
476
493
roleRef:
477
494
apiGroup: rbac.authorization.k8s.io
478
495
kind: Role
479
- name: impersonate:vm:console
496
+ name: impersonate:vm:console:get
480
497
subjects:
481
498
- kind: ServiceAccount
482
499
name: deputy
@@ -499,9 +516,9 @@ Consider including folks who also work outside the SIG or subproject.
499
516
# ### The verbs with `impersonate-on:` prefix has been used by other component.
500
517
501
518
There is possibility that the verbs with prefix of `impersonate-on:` have been
502
- used by other component, and been set in Role/ClusterRole. Since `impersonate`
519
+ used by other component, and been set in Role/ClusterRole. Since `impersonate:<type> `
503
520
permission is also required for impersonator, the component will not get more
504
- power when permssion of `impersonate-on:` is given.
521
+ power when permission of `impersonate-on:` is given.
505
522
506
523
# ### High request volume leads to high load on authorization chain.
507
524
@@ -543,7 +560,7 @@ apiVersion: authorization.k8s.io/v1
543
560
kind: SubjectAccessReview
544
561
spec:
545
562
resourceAttributes:
546
- group: authentications .k8s.io
563
+ group: authentication .k8s.io
547
564
resource: users
548
565
name: someUser
549
566
verb: impersonate:user-info
@@ -559,13 +576,13 @@ apiVersion: authorization.k8s.io/v1
559
576
kind: SubjectAccessReview
560
577
spec:
561
578
resourceAttributes:
562
- group: authentications .k8s.io
579
+ group: authentication .k8s.io
563
580
resource: groups
564
581
name: someGroup
565
582
verb: impersonate:user-info
566
583
user: impersonator
567
584
` ` `
568
- will be sent to the authorizer
585
+ will be sent to the authorizer for each group.
569
586
570
587
# ### Header `Impersonate-Uid` is set
571
588
@@ -575,13 +592,13 @@ apiVersion: authorization.k8s.io/v1
575
592
kind: SubjectAccessReview
576
593
spec:
577
594
resourceAttributes:
578
- group: authentications .k8s.io
595
+ group: authentication .k8s.io
579
596
resource: uids
580
597
name: someUID
581
598
verb: impersonate:user-info
582
599
user: impersonator
583
600
` ` `
584
- will be sent to the authorizer
601
+ will be sent to the authorizer.
585
602
586
603
# ### Header with prefix `Impersonate-Extra-` is set
587
604
@@ -591,14 +608,14 @@ apiVersion: authorization.k8s.io/v1
591
608
kind: SubjectAccessReview
592
609
spec:
593
610
resourceAttributes:
594
- group: authentications .k8s.io
611
+ group: authentication .k8s.io
595
612
resource: userextras
596
613
subresource: extraKey
597
614
name: extraValue
598
615
verb: impersonate:user-info
599
616
user: impersonator
600
617
` ` `
601
- will be sent to the authorizer
618
+ will be sent to the authorizer for each key and value pair.
602
619
603
620
# ## Verb `impersonate:serviceaccount`
604
621
@@ -610,7 +627,7 @@ apiVersion: authorization.k8s.io/v1
610
627
kind: SubjectAccessReview
611
628
spec:
612
629
resourceAttributes:
613
- group: authentications .k8s.io
630
+ group: authentication .k8s.io
614
631
resource: serviceaccounts
615
632
name: serviceaccount-name
616
633
namespace: serviceaccount-namespace
@@ -628,7 +645,7 @@ apiVersion: authorization.k8s.io/v1
628
645
kind: SubjectAccessReview
629
646
spec:
630
647
resourceAttributes:
631
- group: authentications .k8s.io
648
+ group: authentication .k8s.io
632
649
resource: nodes
633
650
name: someNode
634
651
verb: impersonate:nodes
@@ -650,7 +667,7 @@ apiVersion: authorization.k8s.io/v1
650
667
kind: SubjectAccessReview
651
668
spec:
652
669
resourceAttributes:
653
- group: authentications .k8s.io
670
+ group: authentication .k8s.io
654
671
resource: nodes
655
672
verb: impersonate:scheduled-node
656
673
user: impersonator
@@ -661,7 +678,7 @@ apiVersion: authorization.k8s.io/v1
661
678
kind: SubjectAccessReview
662
679
spec:
663
680
resourceAttributes:
664
- group: authentications .k8s.io
681
+ group: authentication .k8s.io
665
682
resource: nodes
666
683
name: node1
667
684
verb: impersonate:node
@@ -756,8 +773,8 @@ This can be done with:
756
773
- The impersonator cannot impersonate alice.
757
774
- The impersonator can impersonate on listing and getting pods
758
775
- The impersonator cannot impersonate on updating pods
759
- - The impersonator can impersonate on getting pod /exec subresource
760
- - The impersonator cannot impersonate on get pod /log subresource
776
+ - The impersonator can impersonate on getting pods /exec subresource
777
+ - The impersonator cannot impersonate on get pods /log subresource
761
778
For RBAC authz mode, this might look like :
762
779
` ` ` yaml
763
780
apiVersion: rbac.authorization.k8s.io/v1
@@ -766,7 +783,7 @@ metadata:
766
783
name: impersonate-bob
767
784
rules:
768
785
- apiGroups:
769
- - authentications .k8s.io
786
+ - authentication .k8s.io
770
787
resources:
771
788
- users
772
789
resourceNames:
@@ -803,7 +820,7 @@ metadata:
803
820
name : impersonate-scheduled-node
804
821
rules :
805
822
- apiGroups :
806
- - authentications .k8s.io
823
+ - authentication .k8s.io
807
824
resources :
808
825
- nodes
809
826
verbs :
@@ -1014,7 +1031,7 @@ This section must be completed when targeting beta to a release.
1014
1031
1015
1032
# ##### How can a rollout or rollback fail? Can it impact already running workloads?
1016
1033
1017
- There is not impact on rollout, the impersonator with existing impersonate permission can still perform the action.
1034
+ There is no impact on rollout, the impersonator with existing impersonate permission can still perform the action.
1018
1035
When the system rollback, impersonator with `impersonate-on:` and `impersonate:` permission will no longer
1019
1036
be authorized to impersonate. Impersonator will need to have the unscoped impersonate permission.
1020
1037
@@ -1025,9 +1042,16 @@ be authorized to impersonate. Impersonator will need to have the unscoped impers
1025
1042
What signals should users be paying attention to when the feature is young
1026
1043
that might indicate a serious problem?
1027
1044
-->
1028
- authorization_attempts_total shows greatly increased number.
1029
- authorization_duration_seconds_bucket shows greatly increased number of request
1030
- with longer duration.
1045
+
1046
+ ` apiserver_authorization_decisions_total` shows greatly increased number.
1047
+ However, we cannot identify the impersonation action from the metrics today.
1048
+ We could introduce a new metrics `apiserver_authorization_decisions_total_by_verb` so that filtering
1049
+ based on impersonation related verbs can tell the number.
1050
+ We could also introduce a new metrics `apiserver_authorization_decisions_duration_seconds`.
1051
+
1052
+ When webhook authorizer is used, if `apiserver_authorization_webhook_evaluations_total` and
1053
+ ` apiserver_authorization_webhook_duration_seconds` shows greatly increase number, users should
1054
+ also pay attention.
1031
1055
1032
1056
# ##### Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?
1033
1057
@@ -1382,7 +1406,7 @@ the action when impersonating.
1382
1406
1383
1407
# ## Expand RBAC/SAR
1384
1408
1385
- Introduce additional API to define more fine grained access control rule, and ref the rule in SAR.
1409
+ Introduce additional API to define more fine- grained access control rule, and ref the rule in SAR.
1386
1410
One example is
1387
1411
1388
1412
` ` ` yaml
@@ -1411,6 +1435,14 @@ And authorizer checks the accessRule on whether a certain impersonate action is
1411
1435
complicated approach that requires changes on existing RBAC/SAR, while the current proposal does not
1412
1436
introduce change on RBAC/SAR.
1413
1437
1438
+ # ### Conditional Authorization
1439
+
1440
+ Conditional authorization is the emerging work to provide more complicated authorization policy
1441
+ with CEL expressions. Potentially it would be able to reduce the number of permission checks for the impersonation
1442
+ in this proposal. The work is still in very early stage, and will bring many changes in the exising authorization
1443
+ model. It is possible to enhance constrained impersonation in this proposal with conditional authorization in the
1444
+ future.
1445
+
1414
1446
# # Infrastructure Needed (Optional)
1415
1447
1416
1448
<!--
0 commit comments