2017-08-10 50 views
0

後不能列出在集羣範圍內的節點,我得到Error from server (Forbidden): User "system:anonymous" cannot list nodes at the cluster scope. (get nodes)kubernetes:從服務器錯誤(禁止):用戶「系統:無名氏」,甚至即使承認集羣角色後用戶授予權限

我有以下設置用戶, - context: cluster: kubernetes user: [email protected] name: [email protected]集在〜/ .kube /配置文件

和下面加到admin.yaml創建集羣作用和集羣rolebindings

kind: CluserRouster: kubernetes user: [email protected] name: [email protected] apiVersion: rbac.authorization.k8s.io/v1alpha1 metadata: name: admin-role rules: - apiGroups: ["*"] resources: ["*"] verbs: ["*"] --- oidckind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1alpha1 metadata: name: admin-binding subjects: - kind: User name: [email protected] roleRef: kind: ClusterRole name: admin-role

當我嘗試命令時,我仍然收到錯誤。 kubectl [email protected] get nodes Error from server (Forbidden): User "system:anonymous" cannot list nodes at the cluster scope. (get nodes)

有人可以請建議如何進行。

回答

1

你的問題不在於你的ClusterRoleBindings,而是在於用戶認證。 Kubernetes告訴你,它確定你爲system:anonymous(類似於* NIX的nobody),而不是[email protected](你應用了你的綁定)。

在您的具體情況下,原因是username標誌使用HTTP基本身份驗證,並需要password標誌來實際執行任何操作。但即使您提供了密碼,您仍然需要實際告訴API服務器接受該特定用戶。

看看this Kubernetes文檔中涉及不同認證方法的部分。要使usernamepassword驗證正常工作,您需要查看靜態密碼文件部分,但我實際上建議您使用X509客戶端證書,因爲它們更安全,操作也更簡單(服務器上無祕密,沒有狀態在API服務器之間複製)。

+0

但在我的情況下,我正在使用OIDC。所以我想我不需要密碼,並且OIDC令牌應該使我能夠登錄。如果我錯了,請糾正我。 – NSP

+0

在這種情況下,您需要從kubectl中刪除'username'選項並在kubectl中正確配置您的OIDC憑證。 – Lorenz

+0

我想用戶需要使用證書和密鑰與apiserver交談。我將不得不使用用戶的電子郵件ID來訪問api服務器。 – NSP