【问题标题】:Creating a ClusterRole as the default compute service account fails with extra privileges error创建 ClusterRole 作为默认计算服务帐户失败并出现额外权限错误
【发布时间】:2019-07-13 04:33:38
【问题描述】:

我正在尝试在我从 Jumpbox 管理的专用集群中创建一个新的 ClusterRole,但一直遇到“禁止:尝试授予额外权限”错误。

我已通过 gcloud 作为默认计算服务帐户进行身份验证,并且该帐户具有 Kubernetes Engine Admin 角色。

我已经为 gcloud 服务帐户创建了一个集群角色绑定,使用

kubectl create ClusterRoleBinding sa-admin-binding --ClusterRole=cluster-admin --User=xxxxxxxx-service-account@xxxx.developer.gserviceaccount.com

当我尝试创建集群角色时,我收到以下错误。

来自服务器的错误(禁止):创建“role.yml”时出错: clusterroles.rbac.authorization.k8s.io “pod-viewer”被禁止: 尝试授予额外权限:[{[list] [] [pods] [] []}] user=&{115268482330004182284 [system:authenticated] 地图[user-assertion.cloud.google.com:[AKUJVpkbsn........

我不明白为什么错误返回的是“编号”用户帐户,而不是我通过身份验证的服务帐户。

我可以使用我自己的 gmail 帐户将 ClusterRoleBinding 添加到 cluster-admin,使用我自己的帐户进行身份验证,然后毫无问题地创建新角色,但是为服务帐户添加 clusterrolebinding,并作为该服务帐户进行身份验证不会似乎授予创建角色的权限。

有趣的是,我可以使用上面错误中的编号帐户添加 clusterrolebinding,这也有效,但不能帮助我编写设置脚本,因为我不知道该数字是什么,也不知道它来自哪里。

【问题讨论】:

    标签: kubernetes google-cloud-platform google-kubernetes-engine


    【解决方案1】:

    嗯...我后来发现编号帐户实际上是 gclouds IAM 控制台中服务帐户的“唯一 ID”。不知道为什么它使用它的服务帐户但对于用户帐户它使用电子邮件地址但这是我现在使用的..

    CLUSTER_ADMIN_ID=`gcloud iam service-accounts describe <my-service-account>@<my-project>.iam.gserviceaccount.com --format="value(uniqueId)"`
    

    紧随其后

    kubectl create ClusterRoleBinding <mybinding>-cluster-admin --clusterrole=cluster-admin --user=$CLUSTER_ADMIN_ID
    

    这允许服务帐户现在管理集群。

    【讨论】:

      猜你喜欢
      • 2019-02-13
      • 1970-01-01
      • 2020-11-03
      • 1970-01-01
      • 2019-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-04
      相关资源
      最近更新 更多