2017-08-10 25 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