kuboard是一个非常好用的k8s集群可视化管理工具,想要给kuboad增加一个只读权限的账号,但是业务上又想用bash功能,进容器执行一些调试的命令,查看kuboard的文档实在是没怎么理解,自己摸索了一下,方案如下
建立用户、用户组(通用只读)
使用admin账号登录kuboard
创建用户

创建用户组

关联用户到用户组

角色绑定

这里绑定viewer角色

到此为止,使用read账号登录kuboard后选择使用ServiceAccount kuboard-viewer可以使用只读权限访问k8s集群,但是无法进行pod exec ,或者其他想要的定制权限


定制权限
创建clusterRole
这里可以创建集群程度的clusterrole或者命名空间层级的role,都可以,按需创建,后续绑定过程相同,这里就可以定制想要的权限了,我这份配置是在k8s view clusterrole的基础上,增加了最后一段pods/exec权限
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
| apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: pod-view-exec-all-namespaces rules: - apiGroups: - "" resources: - configmaps - endpoints - persistentvolumeclaims - persistentvolumeclaims/status - pods - replicationcontrollers - replicationcontrollers/scale - serviceaccounts - services - services/status verbs: - get - list - watch - apiGroups: - "" resources: - bindings - events - limitranges - namespaces/status - pods/log - pods/status - replicationcontrollers/status - resourcequotas - resourcequotas/status verbs: - get - list - watch - apiGroups: - "" resources: - namespaces verbs: - get - list - watch - apiGroups: - apps resources: - controllerrevisions - daemonsets - daemonsets/status - deployments - deployments/scale - deployments/status - replicasets - replicasets/scale - replicasets/status - statefulsets - statefulsets/scale - statefulsets/status verbs: - get - list - watch - apiGroups: - autoscaling resources: - horizontalpodautoscalers - horizontalpodautoscalers/status verbs: - get - list - watch - apiGroups: - batch resources: - cronjobs - cronjobs/status - jobs - jobs/status verbs: - get - list - watch - apiGroups: - extensions resources: - daemonsets - daemonsets/status - deployments - deployments/scale - deployments/status - ingresses - ingresses/status - networkpolicies - replicasets - replicasets/scale - replicasets/status - replicationcontrollers/scale verbs: - get - list - watch - apiGroups: - policy resources: - poddisruptionbudgets - poddisruptionbudgets/status verbs: - get - list - watch - apiGroups: - networking.k8s.io resources: - ingresses - ingresses/status - networkpolicies verbs: - get - list - watch - apiGroups: - metrics.k8s.io resources: - pods - nodes verbs: - get - list - watch - apiGroups: - "" resources: - pods/exec verbs: - create - get - list - watch
|
绑定权限
使用admin账号进入需要授权的集群,进入第二阶段授权,进入用户组界面,这里应该给单个用户授权也是类似逻辑,还没试过。。。

然后就是授权啦



到这里授权就完成了,可以使用read账号登录试试了,需要注意的是,身份需要换一个
