0

我想做一个非常简单的例子来学习如何在 Kubernetes 中使用 RBAC 授权。因此我使用文档中的示例:

kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  namespace: dev
  name: dev-readpods-role
rules:
- apiGroups: [""]
  resources: ["pods"]
  verbs: ["get", "watch", "list"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: dev-tester-rolebinding
  namespace: dev
subjects:
- kind: User
  name: Tester
  apiGroup: rbac.authorization.k8s.io
roleRef:
  kind: Role
  name: dev-readpods-role
  apiGroup: rbac.authorization.k8s.io

创建角色和角色绑定。

当我使用 Tester 登录并尝试

kubectl get pods -n dev

我明白了

Error from server (Forbidden): pods is forbidden: User "<url>:<port>/oidc/endpoint/OP#Tester" cannot list pods in the namespace "dev"

我在这里读到(Kubernetes 中的 RBAC 错误),api-server 必须以 --authorization-mode=...,RBAC 启动。我怎样才能检查这个?我在别的地方读到,如果我跑

kubectl api-versions | findstr rbac

并找到条目 RBAC 应该被激活。真的吗?

我究竟做错了什么?有什么好办法解决问题吗?

谢谢!

PS 我在 IBM Cloud Private 中运行 kubernetes。

4

2 回答 2

0

在 ICP 中,使用 Teams(我认为是 ICP 自己的术语)看起来令人鼓舞。尝试从它开始。但是您需要 ICP 之外的 LDAP 服务器。 https://www.ibm.com/support/knowledgecenter/en/SSBS6K_2.1.0.3/user_management/admin.html

于 2018-09-25T07:19:54.367 回答
0

您需要确定 apiserver 的调用以查看传递给它的 --authorization-mode 标志。通常这包含在 systemd 单元文件或 pod 清单中。我不确定 IBM Cloud 如何启动 apiserver

于 2018-09-24T13:31:57.580 回答