ClusterRoleBinding需要名称空间

问题描述 投票:0回答:2

我有以下内容:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: SomeServiceAccount
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: SomeClusterRole
rules:
  - apiGroups:
      - "myapi.com"
    resources:
      - 'myapi-resources'
    verbs:
      - '*'
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: SomeClusterRoleBinding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: SomeClusterRole
subjects:
  - kind: ServiceAccount
    name: SomeServiceAccount

但是它抛出:The ClusterRoleBinding "SomeClusterRoleBinding" is invalid: subjects[0].namespace: Required value

我认为"Cluster"RoleBinding的全部要点是,它不仅限于单个名称空间。任何人都可以解释吗?

Kubernetes版本1.13.12Kubectl版本v1.16.2谢谢。

kubernetes rbac
2个回答
0
投票
实际上,您应该说的是,ClusterRoleBinding不应绑定到名称空间,而应我认为主题可能会被束缚或束缚(这就是错误的意思)。您可以通过检查特定版本的Kubernetes API规范来调试它。

例如,在主题的名称空间上,here表示:If the object kind is non-namespace, such as "User" or "Group", and this value is not empty the Authorizer should report an error.


0
投票
ClusterRole的群集范围方面是规则中的资源是群集范围的。例如,您可以使用ClusterRole使主题可以访问所有名称空间中的所有Pod。使用角色,您只能授予主题访问特定名称空间中的Pod的权限。

ClusterRoleBinding的群集范围方面在任何情况下都不适用于绑定的主题。在您的示例中,您无法在所有名称空间中为具有特定名称的所有服务帐户创建绑定。

© www.soinside.com 2019 - 2024. All rights reserved.