KubernetesClientException:ClusterRole 或角色
KubernetesClientException: ClusterRole or Role
在使用 Spring Cloud Kubernetes Discovery Client 部署服务时,我收到 KubernetesClientException,指出用户 "default" 被禁止访问 pods。
我已经按照指定添加了角色和角色绑定here
指南指出 ClusterRole 是必要的。但这对我来说不是一个选择,因为我们与其他部门共享集群。我只希望角色影响我们的项目/命名空间。
是否需要 ClusterRole 或 Role 是否足够?
To allow a service account access to these one needs to create a role with the necessary permissions and assign it to the account.This is done with a cluster role, or a role, if one only wants it in
one namespace, and a role binding, which is specific to a namespace.
它说您可以使用 Role 或 ClusterRole。
请记住,在创建角色时应定义 命名空间。即
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: mynamespace
name: service-discovery-client
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["services", "pods", "configmaps", "endpoints"]
verbs: ["get", "watch", "list"]
在使用 Spring Cloud Kubernetes Discovery Client 部署服务时,我收到 KubernetesClientException,指出用户 "default" 被禁止访问 pods。
我已经按照指定添加了角色和角色绑定here
指南指出 ClusterRole 是必要的。但这对我来说不是一个选择,因为我们与其他部门共享集群。我只希望角色影响我们的项目/命名空间。
是否需要 ClusterRole 或 Role 是否足够?
To allow a service account access to these one needs to create a role with the necessary permissions and assign it to the account.This is done with a cluster role, or a role, if one only wants it in one namespace, and a role binding, which is specific to a namespace.
它说您可以使用 Role 或 ClusterRole。
请记住,在创建角色时应定义 命名空间。即
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: mynamespace
name: service-discovery-client
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["services", "pods", "configmaps", "endpoints"]
verbs: ["get", "watch", "list"]