Namespaced Resource
- Role
- Rolebinding
Cluster Resource
- ClusterRole
- ClusterRolebinding
Role系のリソースとBinding系のリソースの組み合わせ
以下は直感的に理解できる。
- RoleとRoleBindingの組み合わせ(青線)
- ClusterRoleとClusterRoleBindingの組み合わせ (緑線)
- RoleとClusterRoleBindingの組み合わせは存在しない。
ClusterRoleとRoleBindingの組み合わせ(赤線)はどうなるのだろうか?
ClusterRoleとRoleBindingの組み合わせ
結論
RoleBindingが所属しないnamespaceのリソースに対してはホワイトリストが適用されない。(getしたりcreateしたりとかできない。)
検証
$ kubectl describe clusterrole hoge Name: hoge Labels: <none> Annotations: <none> PolicyRule: Resources Non-Resource URLs Resource Names Verbs --------- ----------------- -------------- ----- pods/status [] [] [get] pods [] [] [get]
$ kubectl -n default describe rolebinding hoge Name: hoge Labels: <none> Annotations: <none> Role: Kind: ClusterRole Name: hoge Subjects: Kind Name Namespace ---- ---- --------- User user1
$ kubectl auth can-i get pods --namespace=kube-system --as=user1 no $ kubectl auth can-i get pods --namespace=default --as=user1 yes