简体   繁体   English

如何将 kubernetes 仪表板限制为分配给特定角色的用户的特定仪表板

[英]How to restrict kubernetes dashboard to a specific dashboard for a user assigned to a specific Role

I'm trying to restrict the a user on the kubernetes dashboard that connects to kubectl after i created a .crt for him and the respective config.在我为他和相应的配置创建 .crt 后,我​​试图限制连接到 kubectl 的 kubernetes 仪表板上的用户。

I successfully restricted what he can do with the following role.yaml我成功地限制了他可以用以下 role.yaml 做什么

kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
 namespace: development
 name: dev
rules:
- apiGroups: [""]
  resources: ["pods", "services", "crontabs", "pods/log"]
  verbs: ["create", "get", "update", "list", "delete"]
- apiGroups: ["batch"]
  resources: ["cronjobs", "jobs"]
  verbs: ["*"]
- apiGroups: ["apps"]
  resources: ["deployments"]
  verbs: ["create", "get", "update", "list", "delete"]

and cluster binding和集群绑定

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: kubernetes-dashboard-susann
rules:
- apiGroups: [""]
  resources: ["services/proxy"]
  resourceNames: ["https:kubernetes-dashboard:"]
  verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- nonResourceURLs: ["/ui", "/ui/*", "/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/*"]
  verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]

for him to be able to access the dashboard.让他能够访问仪表板。 The problem is that i only want him to be able to access the namespace development .问题是我只希望他能够访问命名空间development

I already searched a bit and some solutions seem to involve creating a service account and another problem might be because the permissions to see the dashboard are giving on a cluster role and that can't be namespaced.我已经进行了一些搜索,一些解决方案似乎涉及创建服务帐户,另一个问题可能是因为查看仪表板的权限授予集群角色并且无法命名。

Is there a best approach to solve this problem?有没有最好的方法来解决这个问题?

This can be done with a proper RBAC configuration.这可以通过适当的 RBAC 配置来完成。

You need to create a RoleBinding in the specific namespace .您需要在特定的namespace创建一个RoleBinding For example, the RBAC rules could be created as follows:例如,可以按如下方式创建 RBAC 规则:

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: dev
  namespace: development
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: edit
subjects:
- apiGroup: rbac.authorization.k8s.io
  kind: Group
  name: dev

With it, the dev Role would have the pre-defined cluster role edit that would restrict them to the standard operations on most objects, via the dashboard.有了它, dev Role将具有预定义的集群角色edit ,通过仪表板将它们限制为对大多数对象的标准操作。 The dev would not be able to drop-down list the other namespaces. dev人员将无法下拉列表其他命名空间。

In order to fully understand the whole process I strongly recommend going through the below guide:为了完全理解整个过程,我强烈建议您阅读以下指南:

If you need to use this or a similar approach for a larger scale, you can consider using this tool:如果你需要在更大范围内使用这种或类似的方法,你可以考虑使用这个工具:

And if you seek more knowledge regarding this particular topic I suggest checking out the below sources:如果您寻求有关此特定主题的更多知识,我建议您查看以下来源:

Going through the guide and supplementing any needed knowledge with the linked sources will make it way easier for you to understand and implement this solution in your use case.通读本指南并使用链接来源补充任何所需的知识,将使您更容易理解并在您的用例中实施此解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM