@@ -76,20 +76,37 @@ tags, and then generate with `hack/update-toc.sh`.
76
76
- [ Goals] ( #goals )
77
77
- [ Non-Goals] ( #non-goals )
78
78
- [ Proposal] ( #proposal )
79
+ - [ Subject Access Review Details] ( #subject-access-review-details )
80
+ - [ workflow when the feature is enabled] ( #workflow-when-the-feature-is-enabled )
79
81
- [ User Stories (Optional)] ( #user-stories-optional )
80
82
- [ Story 1] ( #story-1 )
81
83
- [ Story 2] ( #story-2 )
82
- - [ Notes/Constraints/Caveats (Optional)] ( #notesconstraintscaveats-optional )
83
84
- [ Risks and Mitigations] ( #risks-and-mitigations )
85
+ - [ The verbs with <code >impersonate-on:</code > prefix has been used by other component.] ( #the-verbs-with-impersonate-on-prefix-has-been-used-by-other-component )
86
+ - [ High request volume leads to high load on authorization chain.] ( #high-request-volume-leads-to-high-load-on-authorization-chain )
87
+ - [ Delegating permission of impersonating wildcard action or wildcard subjects is not supported] ( #delegating-permission-of-impersonating-wildcard-action-or-wildcard-subjects-is-not-supported )
84
88
- [ Design Details] ( #design-details )
89
+ - [ Verb <code >impersonate: user-info </code >] ( #verb-impersonateuser-info )
90
+ - [ Header <code >Impersonate-User</code > is set] ( #header-impersonate-user-is-set )
91
+ - [ Header <code >Impersonate-Group</code > is set] ( #header-impersonate-group-is-set )
92
+ - [ Header <code >Impersonate-Uid</code > is set] ( #header-impersonate-uid-is-set )
93
+ - [ Header with prefix <code >Impersonate-Extra-</code > is set] ( #header-with-prefix-impersonate-extra--is-set )
94
+ - [ Verb <code >impersonate: serviceaccount </code >] ( #verb-impersonateserviceaccount )
95
+ - [ Verb <code >impersonate: node </code > and <code >impersonate: scheduled-node </code >] ( #verb-impersonatenode-and-impersonatescheduled-node )
96
+ - [ Auditing] ( #auditing )
85
97
- [ Test Plan] ( #test-plan )
86
98
- [ Prerequisite testing updates] ( #prerequisite-testing-updates )
87
99
- [ Unit tests] ( #unit-tests )
88
100
- [ Integration tests] ( #integration-tests )
89
101
- [ e2e tests] ( #e2e-tests )
90
102
- [ Graduation Criteria] ( #graduation-criteria )
103
+ - [ Alpha] ( #alpha )
104
+ - [ Beta] ( #beta )
105
+ - [ GA] ( #ga )
91
106
- [ Upgrade / Downgrade Strategy] ( #upgrade--downgrade-strategy )
92
107
- [ Version Skew Strategy] ( #version-skew-strategy )
108
+ - [ New kube-apiserver, old <code >impersonate</code > permission] ( #new-kube-apiserver-old-impersonate-permission )
109
+ - [ Old kube-apiserver, new <code >impersonate-on:</code > and <code >impersonate:</code > permission] ( #old-kube-apiserver-new-impersonate-on-and-impersonate-permission )
93
110
- [ Production Readiness Review Questionnaire] ( #production-readiness-review-questionnaire )
94
111
- [ Feature Enablement and Rollback] ( #feature-enablement-and-rollback )
95
112
- [ Rollout, Upgrade and Rollback Planning] ( #rollout-upgrade-and-rollback-planning )
@@ -100,6 +117,11 @@ tags, and then generate with `hack/update-toc.sh`.
100
117
- [ Implementation History] ( #implementation-history )
101
118
- [ Drawbacks] ( #drawbacks )
102
119
- [ Alternatives] ( #alternatives )
120
+ - [ Use <code >impersonate: user-info </code > instead of <code >impersonate: serviceaccount </code > and <code >impersonate: node </code >] ( #use-impersonateuser-info-instead-of-impersonateserviceaccount-and-impersonatenode )
121
+ - [ Subject Access Review] ( #subject-access-review )
122
+ - [ Setting a special APIGroup suffix instead of special verb] ( #setting-a-special-apigroup-suffix-instead-of-special-verb )
123
+ - [ Check permission intersection of impersonator and target user] ( #check-permission-intersection-of-impersonator-and-target-user )
124
+ - [ Expand RBAC/SAR] ( #expand-rbacsar )
103
125
- [ Infrastructure Needed (Optional)] ( #infrastructure-needed-optional )
104
126
<!-- /toc -->
105
127
@@ -192,7 +214,8 @@ Introduce a set of verbs with prefix of `impersonate-on:`, e.g. `impersonate-on:
192
214
` impersonate-on:get` . The impersonator needs to have these verbs with certain resources to
193
215
impersonate.
194
216
195
- Introduce verbs `impersonate:user-info`, `impersonate:serviceaccount` and `impersonate:scheduled-node` :
217
+ Introduce verbs `impersonate:user-info`, `impersonate:serviceaccount`, `impersonate:node` and
218
+ `impersonate:scheduled-node` :
196
219
- ` impersonate:user-info` limits the impersonator to impersonate users with
197
220
certain names/groups/userextras. The resources must be `users`/`groups`/`userextras`/`uids`.
198
221
and the user must not be a node (username with a prefix of `system:nodes`)
@@ -206,13 +229,14 @@ verb to impersonate a node.
206
229
impersonator is running on. The resources must be `nodes`.
207
230
208
231
For clusters that use RBAC authz mode, two permissions will be required for impersonation. For example :
209
- 1. The permission to impersonate a certain user. This is a cluster scoped
210
- permission.
232
+ to express "system:serviceaccount:default:default can impersonate a user named someUser solely to list
233
+ and watch pods in the default namespace."
234
+ 1. The permission to constrained impersonate a certain user. This is a cluster scoped permission.
211
235
` ` ` yaml
212
236
apiVersion: rbac.authorization.k8s.io/v1
213
237
kind: ClusterRole
214
238
metadata:
215
- name: impersonate
239
+ name: constrained- impersonate-only-someUser
216
240
rules:
217
241
- apiGroups:
218
242
- authentications.k8s.io
@@ -272,7 +296,7 @@ These permissions define: "The impersonator can impersonate a user with the name
272
296
someUser to list and watch pods in the default namespace."
273
297
274
298
# ## Subject Access Review Details
275
- When receiving an impersonation request to list pods cluster-wid from the user `impersonator`
299
+ When receiving an impersonation request to list pods cluster-wide from the user `impersonator`
276
300
with the header of `Impersonate-User:someUser`, the apiserver :
277
301
- Verifies if the impersonator has the permission to impersonate with the scope of the user.
278
302
A subjectaccessreview is sent to the authorizer :
@@ -295,6 +319,7 @@ kind: SubjectAccessReview
295
319
spec:
296
320
resourceAttributes:
297
321
resource: pods
322
+ namespace: default
298
323
verb: impersonate-on:list
299
324
user: impersonator
300
325
` ` `
@@ -471,11 +496,17 @@ power when permssion of `impersonate-on:` is given.
471
496
For the scheduled node case, it is possible that a high request volume node
472
497
agent could be constantly performing impersonated requests, each of which would
473
498
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.
499
+ chain. Comparing to other alternatives which would also introduce at least
500
+ one authorization check for each request call, the proposal is able to
501
+ satisfy more use case.
502
+
503
+ # ### Delegating permission of impersonating wildcard action or wildcard subjects is not supported
504
+
505
+ Permissions must be delegated using specified verbs with the prefix of `impersonate:` and
506
+ ` impersonate-on:` . Expressing a permission to impersonate ANY subject or ANY action is not
507
+ possible, since the authorization model does not have the concept of partial wildcard on verbs.
508
+ It should be ok since all these permission for constrained impersonation are strictly additive which
509
+ means it should be added when certain impersonation requests are needed.
479
510
480
511
# # Design Details
481
512
@@ -708,12 +739,19 @@ This can be done with:
708
739
- a search in the Kubernetes bug triage tool (https://storage.googleapis.com/k8s-triage/index.html)
709
740
-->
710
741
711
- - SubjectAccessReview check on impersonating user. For RBAC authz mode, this might look like :
742
+ - SubjectAccessReview check on impersonating user.
743
+ - The impersonator can impersonate bob.
744
+ - The impersonator cannot impersonate alice.
745
+ - The impersonator can impersonate on listing and getting pods
746
+ - The impersonator cannot impersonate on updating pods
747
+ - The impersonator can impersonate on getting pod/exec subresource
748
+ - The impersonator cannot impersonate on get pod/log subresource
749
+ For RBAC authz mode, this might look like :
712
750
` ` ` yaml
713
751
apiVersion: rbac.authorization.k8s.io/v1
714
752
kind: ClusterRole
715
753
metadata:
716
- name: impersonate-user
754
+ name: impersonate-bob
717
755
rules:
718
756
- apiGroups:
719
757
- authentications.k8s.io
@@ -727,28 +765,30 @@ rules:
727
765
apiVersion: rbac.authorization.k8s.io/v1
728
766
kind: Role
729
767
metadata:
730
- name: impersonate:vm:console
768
+ name: impersonate-pod-action
731
769
namespace: default
732
770
rules:
733
- - apiGroups:
734
- - ""
735
- resources:
736
- - nodes
771
+ - resources:
772
+ - pods
773
+ - pod/exec
737
774
verbs:
738
775
- impersonate-on:list
776
+ - impersonate-on:get
739
777
` ` `
740
- - The impersonator can impersonate bob.
741
- - The impersonator cannot impersonate alice.
742
- - The impersonator can impersonate on listing nodes
743
- - The impersonator cannot impersonate on updating nodes
744
-
745
- - SAR check on impersonate scheduled node with permissions. The impersonator has the
778
+ - SAR check on impersonating scheduled node with permissions. The impersonator has the
746
779
user extra info of `"authentication.kubernetes.io/node-name" : " node1" `
780
+ - The impersonator can impersonate node1.
781
+ - The impersonator cannot impersonate node2.
782
+ - The impersonator cannot impersonate bob.
783
+ - The impersonator can impersonate on listing pods.
784
+ - The impersonator cannot impersonate on updating pods,
785
+
786
+ with the permission like this:
747
787
` ` ` yaml
748
788
apiVersion : rbac.authorization.k8s.io/v1
749
789
kind : ClusterRole
750
790
metadata :
751
- name : impersonate-user
791
+ name : impersonate-scheduled-node
752
792
rules :
753
793
- apiGroups :
754
794
- authentications.k8s.io
@@ -760,7 +800,7 @@ rules:
760
800
apiVersion : rbac.authorization.k8s.io/v1
761
801
kind : Role
762
802
metadata :
763
- name : impersonate:vm:console
803
+ name : impersonate-pod-action
764
804
namespace : default
765
805
rules :
766
806
- apiGroups :
@@ -770,18 +810,30 @@ rules:
770
810
verbs :
771
811
- impersonate-on:list
772
812
` ` `
773
- - The impersonator can impersonate node1.
774
- - The impersonator cannot impersonate node2.
775
- - The impersonator cannot impersonate bob.
776
- - The impersonator can impersonate on listing pods.
777
- - The impersonator cannot impersonate on updating pods,
778
813
779
- - [test name](https://github.com/kubernetes/kubernetes/blob/2334b8469e1983c525c0c6382125710093a25883/test/integration/...): [integration master](https://testgrid.k8s.io/sig-release-master-blocking#integration-master?include-filter-by-regex=MyCoolFeature), [triage search](https://storage.googleapis.com/k8s-triage/index.html?test=MyCoolFeature)
814
+ - SAR check on impersonating service account
815
+ - SAR check on impersonating nodes
816
+
817
+ Each test should cover positive and negative cases with multiple resources and verbs.
818
+
819
+ - Permission delegation:
820
+ - bob has the ` impersonate:user-info` permission, and can delegate the `impersonate:user-info`
821
+ permission to alice.
822
+ - bob cannot delegate the `impersonate:node` permission to alice.
823
+ - bob has the `impersonate:list` permission on pods resource, and can delegate the permission
824
+ to alice.
825
+ - bob cannot delegate the `impersonate:update` permission on pods resource to alice.
780
826
781
827
# #### e2e tests
782
828
783
- This feature is fully tested with unit and integration tests. An eventual conformance
784
- test is needed as part of GA
829
+ In addition to testing with unit and integration tests. E2E tests will be added covering below cases.
830
+
831
+ - A user cannot impersonate a subresource until the correct constrained impersonation permissions is
832
+ set for the user.
833
+ - A sericeaccount with the correct constrained impersonation permission is able to impersonate
834
+ the node to list pods.
835
+
836
+ An eventual conformance test is needed as part of GA.
785
837
786
838
- [test name](https://github.com/kubernetes/kubernetes/blob/2334b8469e1983c525c0c6382125710093a25883/test/e2e/...) : [SIG ...](https://testgrid.k8s.io/sig-...?include-filter-by-regex=MyCoolFeature), [triage search](https://storage.googleapis.com/k8s-triage/index.html?test=MyCoolFeature)
787
839
@@ -823,8 +875,7 @@ Below are some examples to consider, in addition to the aforementioned [maturity
823
875
824
876
- Determine if additional tests are necessary
825
877
- Ensure reliability of existing tests
826
- - Determine if some caching mechanism should be introduced to reduce the extra
827
- permission check call
878
+ - Determine if some mechanism should be introduced to reduce the extra permission checks
828
879
829
880
# ### GA
830
881
@@ -924,7 +975,7 @@ Yes. Set the feature gate to false and restart the kube-apiserver.
924
975
925
976
# ##### What happens if we reenable the feature if it was previously rolled back?
926
977
927
- No addtional configuration is needed.
978
+ No additional configuration is needed.
928
979
929
980
# ##### Are there any tests for feature enablement/disablement?
930
981
@@ -1253,6 +1304,18 @@ Major milestones might include:
1253
1304
1254
1305
# # Alternatives
1255
1306
1307
+ # ## Use `impersonate:user-info` instead of `impersonate:serviceaccount` and `impersonate:node`
1308
+
1309
+ Verb `impersonate:serviceaccount` and `impersonate:node` are special cases of verb
1310
+ ` impersonate:user-info` . Without these two verbs, it is still possible to use verb
1311
+ ` impersonate:user-info` with certain username, e.g. username with the prefix
1312
+ ` system:serviceaccounts:` or the prerix `system:nodes`. However, providing the two special
1313
+ verbs would delegation of permissions and support more expressions :
1314
+
1315
+ - Verb `impersonate:serviceaccount` can support a permission to allow impersonating any
1316
+ serviceaccounts in a certain namespace.
1317
+ - Verb `impersonate:node` can support a permission to allow impersonating any node.
1318
+
1256
1319
# ## Subject Access Review
1257
1320
1258
1321
The controller can sends a SAR request, and then uses its own permission to perform the action.
0 commit comments