为Kubernetes仪表板访问用户添加权限控制
(TOC)
1。需求
在开发环境给开发人员创建应用部署管理权限,可以使用仪表板的令牌和kubeconfig文件登录,并在开发人员机器上安装<代码> kubectl 代码>命令,可以使用<代码> kubectl左前代码>命令。
2。方案
因为我们用到了仪表板和kubeapps,所以他们的rbac权限都要分配。
创建名称空间:<代码> dev 代码>
创建ServiceAccount: <代码> dev-user1 代码>
给相应权限,并绑定ServiceAccount。
3。实现
3.1分配仪表板权限
<代码> kubectl应用- f dev-user1.yaml 代码>
<代码类=" language-yaml "> - - - - - - # ServiceAccount apiVersion: v1 :ServiceAccount 元数据: 名称:dev-user1 名称空间:开发 --- #角色 类型:角色 apiVersion: rbac.authorization.k8s.io/v1 元数据: 名称空间:开发 名称:role-dev-user1 规则: - apiGroups: ["] 资源(“豆荚”): 动词:[“获得”,“列表”,“看”,“删除”,“更新”,“补丁”) - apiGroups: ["] 资源:["豆荚/portforward”、“豆荚/代理”) 动词:[“获得”,“列表”,“看”,“创造”,“更新”,“补丁”,“删除”) - apiGroups: ["] 资源(“豆荚/日志”): 动词:[“获得”,“列表”,“看”,“删除”) - apiGroups:(“扩展”,“应用程序”) 资源(“部署”): 动词:[“获得”,“列表”,“看”,“创造”,“更新”,“补丁”,“删除”) - apiGroups: ["] 资源(“名称空间”): 动词:[“得到”,“看”,“名单”) - apiGroups: ["] 资源(“事件”): 动词:[“得到”,“看”,“名单”) ——apiGroups:(“应用程序”、“扩展”) 资源(“replicasets”): 动词:[“得到”、“看”、“列表”,“创造”,“更新”,“pathch”,“删除”) - apiGroups: ["] 资源(“configmaps”): 动词:[“得到”、“看”、“列表”,“创造”,“更新”,“pathch”,“删除”) - apiGroups: ["] 资源(“persistentvolumeclaims”): 动词:[“得到”,“看”,“名单”) - apiGroups: ["] 资源(“秘密”): 动词:[“得到”,“看”,“名单”) - apiGroups: ["] 资源(“服务”): 动词:[“得到”、“看”、“列表”,“创造”,“更新”,“pathch”,“删除”) ——apiGroups(“扩展”): 资源(“入口”): 动词:[“得到”,“看”,“名单”) ——apiGroups(“应用程序”): 资源(“daemonsets”): 动词:[“得到”,“看”,“名单”) ——apiGroups(“批处理”): 资源(“工作”): 动词:[“得到”,“看”,“名单”) ——apiGroups(“批处理”): 资源(“计划”): 动词:[“得到”,“看”,“名单”) - apiGroups: ["] 资源(“replicationcontrollers”): 动词:[“得到”,“看”,“名单”) ——apiGroups(“应用程序”): 资源(“statefulsets”): 动词:[“得到”,“看”,“名单”) - apiGroups: ["] 资源(“端点”): 动词:[“得到”,“看”,“名单”) --- #角色绑定 :RoleBinding apiVersion: rbac.authorization.k8s.io/v1 元数据: 名称:role-bind-dev-user1 名称空间:开发 主题: 类型:ServiceAccount 名称:dev-user1 名称空间:开发 roleRef: 类型:角色 名称:role-dev-user1 apiGroup: rbac.authorization.k8s.io # - - - - - - # # clusterrole #:ClusterRole # apiVersion: rbac.authorization.k8s.io/v1 #元数据: 名称空间:开发 #名称:clusterrole-dev-user1 #规则: # - apiGroups: ["] #资源(“名称空间”): #动词:[“获得”,“看”,“名单”) # # - - - - - - # # clusterrole绑定 #:ClusterRoleBinding # apiVersion: rbac.authorization.k8s.io/v1 #元数据: #名称:clusterrole-bind-dev-user1 名称空间:开发 #话题: # -类:ServiceAccount #名称:dev-user1 名称空间:开发 # roleRef: #:ClusterRole #名称:clusterrole-dev-user1 # apiGroup: rbac.authorization.k8s.io 代码>
3.2分配kubeapps权限
<代码类=" language-bash "> kubectl应用- f https://raw.githubusercontent.com/kubeapps/kubeapps/master/docs/user/manifests/kubeapps-applications-read.yaml kubectl创建- n dev rolebinding dev-user1-view \ ——clusterrole=kubeapps-applications-read \ ——serviceaccount dev: dev-user1为Kubernetes仪表板访问用户添加权限控制