简体   繁体   English

Kube.netes 仪表板访问具有相同令牌或配置文件的命名空间

[英]Kubernetes dashboard access to namespaces with same token or config file

I want to create a kube.netes user who can access k8s dashboard to only few namespaces(let's assume 3 namespaces) using same token or config file and user should be able to use kubectl to get information from cluster with config file.我想创建一个 kube.netes 用户,该用户只能使用相同的令牌或配置文件访问 k8s 仪表板到几个命名空间(假设 3 个命名空间),并且用户应该能够使用 kubectl 从带有配置文件的集群中获取信息。 Is this something achievable?这是可以实现的吗?

I tried creating Role and Rolebinding for user but with this, user can access from the command line interface but not from dashboard because token is not generated.我尝试为用户创建角色和角色绑定,但是有了这个,用户可以从命令行界面访问,但不能从仪表板访问,因为没有生成令牌。 Followed this process https://www.openlogic.com/blog/granting-user-access-your-kube.netes-cluster遵循这个过程https://www.openlogic.com/blog/granting-user-access-your-kube.netes-cluster

Other option I tried is to create a user as service account in each namespace and I could able to generate dashboard token, but the problem is user will have separate token for each namespace and separate config file for each namespace.我尝试的另一个选项是在每个命名空间中创建一个用户作为服务帐户,我可以生成仪表板令牌,但问题是用户将为每个命名空间拥有单独的令牌,并为每个命名空间拥有单独的配置文件。 Every time user has to logout from dashboard to switch between namespaces, this works but very inconvenient for developers.每次用户必须从仪表板注销才能在命名空间之间切换时,这对开发人员来说非常不方便。

Is there any better option?有没有更好的选择? my requirement is 1. Create a user who can access k8s cluster from command line and also dashboard to only few namespaces access with single config file and single dashboard token.我的要求是 1. 创建一个用户,该用户可以从命令行访问 k8s 集群,也可以使用单个配置文件和单个仪表板令牌访问仪表板,仅访问几个命名空间。

If you define a clusterrole such a way that it gives permission to few namespaces and create a clusterrolebinding to bind that clusterrole to the service account then the same token will effectively have permission to all those namespaces.如果您定义一个clusterrole的方式是它向少数命名空间授予权限,并创建一个clusterrolebinding clusterrole到服务帐户,那么同一个令牌将有效地拥有对所有这些命名空间的权限。

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

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