web-dev-qa-db-ja.com

サーバーからのエラー(禁止):..の作成時のエラー:clusterroles.rbac.authorization.k8s.io ...:追加の権限の付与を試みます:

Clusterrolesの作成に失敗しました。 <>「コンテナエンジン管理者」および「コンテナエンジンクラスタ管理者」の役割として既に割り当てられています

Error from server (Forbidden): error when creating "prometheus-
operator/prometheus-operator-cluster-role.yaml":
clusterroles.rbac.authorization.k8s.io "prometheus-operator"
is forbidden: attempt to grant extra privileges: [{[create]
[extensions] [thirdpartyresources] [] []} {[*]
[monitoring.coreos.com] [alertmanagers] [] []} {[*]
[monitoring.coreos.com] [prometheuses] [] []} {[*]
[monitoring.coreos.com] [servicemonitors] [] []} {[*]
[apps] [statefulsets] [] []} {[*] [] [configmaps] [] []}
{[*] [] [secrets] [] []} {[list] [] [pods] [] []} {[delete]
[] [pods] [] []} {[get] [] [services] [] []} {[create]
[] [services] [] []} {[update] [] [services] [] []} {[get]
[] [endpoints] [] []} {[create] [] [endpoints] [] []}
{[update] [] [endpoints] [] []} {[list] [] [nodes]
[] []} {[watch] [] [nodes] [] []}]
user=&{<<my_account>>@gmail.com
[system:authenticated] map[]} ownerrules=[{[create]
[authorization.k8s.io] [selfsubjectaccessreviews]
[] []} {[get] [] [] [] [/api /api/* /apis /apis/*
/healthz /swaggerapi /swaggerapi/* /version]}]
ruleResolutionErrors=[]
20
ccyang2005

https://cloud.google.com/container-engine/docs/role-based-access-control#setting_up_role-based_access_control に基づく

「Role」または「ClusterRole」を作成するときにContainer Engineが権限をチェックする方法のため、作成するロールに含まれるすべての権限を付与する「RoleBinding」を最初に作成する必要があります。

回避策の例は、追加の「ロール」または「クラスターロールの許可」を作成する前に、Google IDに「クラスター管理者」ロールを付与する「ロールバインディング」を作成することです。

これは、KubernetesおよびContainer Engineバージョン1.6の役割ベースのアクセス制御のベータリリースでの既知の問題です。

そのため、アカウントをクラスター管理者ロールにバインドする必要があります。

12
monis

Google Kubernetes Engineでも同じ問題が発生しています。

enjの答えとccyang2005のコメントによると、私の問題を解決する次のスニペットを見つけてください:)

ステップ1:IDを取得する

gcloud info | grep Account

Account: [[email protected]]のようなものを出力します

ステップ2:現在のIDにcluster-adminを付与します

kubectl create clusterrolebinding myname-cluster-admin-binding \
  --clusterrole=cluster-admin \
  [email protected]

Clusterrolebinding "myname-cluster-admin-binding" createdのようなものを出力します


その後、CusterRolesを作成できるようになります

44
alphayax