Seb*_*sch 11 rbac google-cloud-platform kubernetes google-kubernetes-engine
创建新的GKE集群后,创建集群角色失败,并显示以下错误:
Error from server (Forbidden): error when creating "./role.yaml":
clusterroles.rbac.authorization.k8s.io "secret-reader" is forbidden:
attempt to grant extra privileges: [PolicyRule{Resources:["secrets"],
APIGroups:[""], Verbs:["get"]} PolicyRule{Resources:["secrets"],
APIGroups:[""], Verbs:["watch"]} PolicyRule{Resources:["secrets"],
APIGroups:[""], Verbs:["list"]}] user=&{XXX@gmail.com
[system:authenticated] map[authenticator:[GKE]]} ownerrules= .
[PolicyRule{Resources:["selfsubjectaccessreviews"
"selfsubjectrulesreviews"], APIGroups:["authorization.k8s.io"], Verbs:
["create"]} PolicyRule{NonResourceURLs:["/api" "/api/*" "/apis"
"/apis/*" "/healthz" "/swagger-2.0.0.pb-v1" "/swagger.json"
"/swaggerapi" "/swaggerapi/*" "/version"], Verbs:["get"]}]
ruleResolutionErrors=[]
Run Code Online (Sandbox Code Playgroud)
我的帐户在IAM中具有以下权限:
Kubernetes Engine Admin
Kubernetes引擎集群管理员
所有者
这是我的role.yaml
(来自Kubernetes文档):
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: secret-reader
rules:
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get", "watch", "list"]
Run Code Online (Sandbox Code Playgroud)
根据RBAC的GCloud文档,我需要
在尝试创建其他Role或ClusterRole权限之前,创建一个RoleBinding,为您的Google身份提供群集管理员角色.
所以我尝试了这个:
export GCP_USER=$(gcloud config get-value account | head -n 1)
kubectl create clusterrolebinding cluster-admin-binding
--clusterrole=cluster-admin --user=$GCP_USER
Run Code Online (Sandbox Code Playgroud)
哪个成功,但在创建集群角色时仍然会遇到相同的错误.
我有什么想法可能做错了吗?
小智 9
根据Google容器引擎文档,您必须首先创建一个RoleBinding,它授予您要创建的角色中包含的所有权限.
$ gcloud info | grep Account
Account: [myname@example.org]
Run Code Online (Sandbox Code Playgroud)
$ kubectl create clusterrolebinding myname-cluster-admin-binding --clusterrole=cluster-admin --user=myname@example.org
Clusterrolebinding "myname-cluster-admin-binding" created
Run Code Online (Sandbox Code Playgroud)
现在您可以毫无问题地创建ClusterRole.
我在CoreOS FAQ/Troubleshooting中找到了答案,请查看更多信息.
这是正确的解决方案。XXX@gmail.com
获取到的GCP_USER与创建角色错误信息中的用户名是否相同?
归档时间: |
|
查看次数: |
2276 次 |
最近记录: |