java系统找不到指定文件怎么解决
252
2022-09-12
k8s-apiServer鉴权
1.介绍
在 Kubernetes 项目中,负责完成授权(Authorization)工作的机制,就是 RBAC:基于角色的访问控制(Role-Based Access Control)。
Role:角色,它其实是一组规则,定义了一组对 Kubernetes API 对象的操作权限。
Subject:被作用者,即User或ServiceAccount。
RoleBinding:定义了“被作用者”和“角色”的绑定关系。
2.RoleBinding
只针对指定Namespace生效
创建ServiceAccount
apiVersion: v1kind: ServiceAccountmetadata: namespace: mynamespace name: example-sa
设置role:example-role的权限
拥有pod的"get", "watch", "list"权限
拥有某个pod的"get", "watch", "list"权限
kind: RoleapiVersion: rbac.authorization.k8s.io/v1metadata: namespace: mynamespace name: example-rolerules:- apiGroups: [""] resources: ["pods"] resourceNames: ["my-pod"] verbs: ["get", "watch", "list"]
设置哪个User拥有上面的角色
这里的user需要通过外部认证服务,比如 Keystone,来提供。
kind: RoleBindingapiVersion: rbac.authorization.k8s.io/v1metadata: name: example-rolebinding namespace: mynamespacesubjects:- kind: User name: example-user apiGroup: rbac.authorization.k8s.ioroleRef: kind: Role name: example-role apiGroup: rbac.authorization.k8s.io
设置哪个ServiceAccount拥有上面的角色
kind: RoleBindingapiVersion: rbac.authorization.k8s.io/v1metadata: name: example-rolebinding namespace: mynamespacesubjects:- kind: ServiceAccount name: example-sa namespace: mynamespaceroleRef: kind: Role name: example-role apiGroup: rbac.authorization.k8s.io
3.ClusterRoleBinding
对所有Namespace生效
设置ClusterRole权限
kind: ClusterRoleapiVersion: rbac.authorization.k8s.io/v1metadata: name: example-clusterrolerules:- apiGroups: [""] resources: ["pods"] verbs: ["get", "watch", "list"]
设置哪个ServiceAccount拥有上面的角色
kind: ClusterRoleBindingapiVersion: rbac.authorization.k8s.io/v1metadata: name: example-clusterrolebindingsubjects:- kind: ServiceAccount name: example-sa namespace: mynamespaceroleRef: kind: ClusterRole name: example-clusterrole apiGroup: rbac.authorization.k8s.io
4.Group概念
Kubernetes 还拥有“用户组”(Group)的概念,也就是一组“用户”的意思。
一个 ServiceAccount,在 Kubernetes 里对应的“用户”的名字是:
system:serviceaccount:
它对应的内置“用户组”的名字,就是
system:serviceaccounts:
举例如下规则1:
意味着这个 Role 的权限规则,作用于整个系统里的所有 ServiceAccount
subjects:- kind: Group name: system:serviceaccounts apiGroup: rbac.authorization.k8s.io
举例如下规则2:
意味着这个 Role 的权限规则,作用于 mynamespace 里的所有 ServiceAccount。这就用到了“用户组”的概念。
subjects:- kind: Group name: system:serviceaccounts:mynamespace apiGroup: rbac.authorization.k8s.io
更多介绍查看我的另一篇文章
https://blog./u_10983441/4976185
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~