为 kubernetes 命名空间创建自定义角色时出现此错误。
RBAC 错误:来自服务器的错误(禁止):创建“role-qa.yaml”时出错:role.rbac.authorization.k8s.io“qa-role”被禁止
我已经在许多版本的 kubernetes 上尝试过这个。我已经检查了各种用户提供的关于为用户分配“集群管理员”角色的许多解决方案,并做了同样的事情,但仍然没有解决这个问题。
以下是所需的详细信息。
命名空间.yaml
apiVersion: v1
kind: Namespace
metadata:
name: qa
---
apiVersion: v1
kind: Namespace
metadata:
name: prod
我已经仔细检查了用于 kubernetes 访问的用户,如下所示。
gcloud 配置列表
输出 :
[core]
account = xyz@gmail.com
disable_usage_reporting = True
project = sonar-198615
gcloud 授权列表
输出:
Credentialed Accounts
ACTIVE ACCOUNT
* xyz@gmail.com
To set the active account, run:
$ gcloud config set account `ACCOUNT`
我还检查了集群角色是否分配给用户,并且用户具有集群管理员角色。
以下是我得到的完整错误。
Error from server (Forbidden): error when creating "role-qa.yaml":
roles.rbac.authorization.k8s.io "qa-role" is forbidden: attempt to
grant extra privileges: [PolicyRule{APIGroups:[""],
Resources:["pods"], Verbs:["get"]} PolicyRule{APIGroups:[""],
Resources:["pods"], Verbs:["watch"]} PolicyRule{APIGroups:[""],
Resources:["pods"], Verbs:["list"]}] user=&{xyz@gmail.com
[system:authenticated]
map[user-assertion.cloud.google.com:[AF1jyJCtSZd2sdmeNfdVbJyylD/nTw8h9aQznfgDOI8n4n7MlK9ncU0r+UXrVCgySWVv4wJHg85db75ekmhV67qyxwVP7tv0KzEKtEz7agxSXSu+qZsxBjoKHIQpjlhrT9mc7cRAvB/OxTxvi8xexAC7fvf563Ttwoejx11F6Bs3qXElIhDDtTKT0O8S0eWIFcHoWMrs+nIdvcsbXaQLHL4+E2+Uufjrp3f+8nyC]]}
ownerrules=[PolicyRule{APIGroups:["authorization.k8s.io"],
Resources:["selfsubjectaccessreviews" "selfsubjectrulesreviews"],
Verbs:["create"]} PolicyRule{NonResourceURLs:["/api" "/api/*" "/apis"
"/apis/*" "/healthz" "/openapi" "/openapi/*" "/swagger-2.0.0.pb-v1"
"/swagger.json" "/swaggerapi" "/swaggerapi/*" "/version" "/version/"],
Verbs:["get"]}] ruleResolutionErrors=[]
如果有人需要这方面的任何进一步信息,请告诉我。