【问题标题】:How to list my current RBAC roles and groups I belong to?如何列出我当前所属的 RBAC 角色和组?
【发布时间】:2019-03-11 16:59:22
【问题描述】:

我通过了 kubernetes 集群的身份验证,如何查看附加到我当前帐户的 RBAC 角色和组?

【问题讨论】:

标签: kubernetes rbac


【解决方案1】:

找到更好的工具

这个工具看起来比 rakkess 好得多
正是我要找的东西

https://github.com/reactiveops/rbac-lookup

在最简单的用例中,rbac-lookup 将返回任何匹配的用户、服务帐户或组以及它所赋予的角色。

rbac-lookup rob

SUBJECT                   SCOPE             ROLE
rob@example.com           cluster-wide      ClusterRole/view
rob@example.com           nginx-ingress     ClusterRole/edit
The wide output option includes the kind of subject along with the source role binding.
rbac-lookup ro --output wide

SUBJECT                   SCOPE             ROLE                SOURCE
User/rob@example.com      cluster-wide      ClusterRole/view    ClusterRoleBinding/rob-cluster-view
User/rob@example.com      nginx-ingress     ClusterRole/edit    RoleBinding/rob-edit
User/ron@example.com      web               ClusterRole/edit    RoleBinding/ron-edit
ServiceAccount/rops       infra             ClusterRole/admin   RoleBinding/rops-admin

【讨论】:

  • 您可以通过krew使用这些工具及更多内容
【解决方案2】:

按照以下步骤操作

  1. 安装 go 并验证它是否存在
master $ echo $GOPATH
/opt/go
  1. 创建和验证
master $ mkdir -p $GOPATH/bin
  1. 安装 rakkess
curl -Lo rakkess.gz https://github.com/corneliusweig/rakkess/releases/download/v0.2.0/rakkess-linux-amd64.gz && \
  gunzip rakkess.gz && chmod +x rakkess \
  && mv rakkess $GOPATH/bin/
  1. 列出特定命名空间中的权限
rakkess --namespace <namespace-name>
  1. 您应该会看到以下格式的输出
master $ rakkess -n kube-system
NAME                                            LIST  CREATE  UPDATE  DELETE
bindings                                              ✔
configmaps                                      ✔     ✔       ✔       ✔
controllerrevisions.apps                        ✔     ✔       ✔       ✔
cronjobs.batch                                  ✔     ✔       ✔       ✔
daemonsets.apps                                 ✔     ✔       ✔       ✔
daemonsets.extensions                           ✔     ✔       ✔       ✔
deployments.apps                                ✔     ✔       ✔       ✔
deployments.extensions                          ✔     ✔       ✔       ✔
endpoints                                       ✔     ✔       ✔       ✔
events                                          ✔     ✔       ✔       ✔
events.events.k8s.io                            ✔     ✔       ✔       ✔
horizontalpodautoscalers.autoscaling            ✔     ✔       ✔       ✔
ingresses.extensions                            ✔     ✔       ✔       ✔
jobs.batch                                      ✔     ✔       ✔       ✔
limitranges                                     ✔     ✔       ✔       ✔
localsubjectaccessreviews.authorization.k8s.io        ✔
networkpolicies.extensions                      ✔     ✔       ✔       ✔
networkpolicies.networking.k8s.io               ✔     ✔       ✔       ✔
persistentvolumeclaims                          ✔     ✔       ✔       ✔
poddisruptionbudgets.policy                     ✔     ✔       ✔       ✔
pods                                            ✔     ✔       ✔       ✔
podtemplates                                    ✔     ✔       ✔       ✔
replicasets.apps                                ✔     ✔       ✔       ✔
replicasets.extensions                          ✔     ✔       ✔       ✔
replicationcontrollers                          ✔     ✔       ✔       ✔
resourcequotas                                  ✔     ✔       ✔       ✔
rolebindings.rbac.authorization.k8s.io          ✔     ✔       ✔       ✔
roles.rbac.authorization.k8s.io                 ✔     ✔       ✔       ✔
secrets                                         ✔     ✔       ✔       ✔
serviceaccounts                                 ✔     ✔       ✔       ✔
services                                        ✔     ✔       ✔       ✔
statefulsets.apps                               ✔     ✔       ✔       ✔

【讨论】:

  • 感谢您的回答!我已经检查了 rakkess,但这显示了我能做什么,“动词”,但是如何列出附加到我的角色?
  • 没有直接的方法。检查此链接 --> stackoverflow.com/questions/43186611/…
猜你喜欢
  • 2011-02-19
  • 2019-12-21
  • 1970-01-01
  • 1970-01-01
  • 2014-03-09
  • 2016-03-25
  • 1970-01-01
  • 2010-10-20
  • 1970-01-01
相关资源
最近更新 更多