我遇到了一个奇怪的问题,不知道我是不是疯了。我有以下的角色绑定和集群角色绑定yaml:
# Standard CLI role, some executable dashboard permissions.
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: company-engineer-binding
namespace: company-ns
subjects:
- kind: ServiceAccount
name: testseven
apiGroup: ""
- kind: ServiceAccount
name: testsix
apiGroup: ""
roleRef:
kind: Role
name: company-engineer
apiGroup: ""
---
# Used to handle a few read-only permissions on the dashboard (listing)
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: company-engineer-dashboard-clusterbinding
subjects:
- kind: ServiceAccount
name: testseven
namespace: company-ns
- kind: ServiceAccount
name: testsix
namespace: company-ns
roleRef:
kind: ClusterRole
name: company-engineer-dashboard
apiGroup: rbac.authorization.k8s.io
每一个都有一个关联的角色/集群角色,并且已经过验证。问题是,当使用kubectl apply -f应用这个yaml时,它只将角色应用到列表中的第一个主题。因此,在上面的示例中,只有testseven ServiceAccount获得这些角色,而testsix帐户什么也得不到。
[root@k8s-m01 yaml]# kubectl get rolebinding,clusterrolebinding,role,clusterrole --all-namespaces -o jsonpath='{range .items[?(@.subjects[0].name=="testseven")]}[{.roleRef.kind},{.roleRef.name}]{end}'
[Role,company-engineer][ClusterRole,company-engineer-dashboard]
[root@k8s-m01 yaml]# kubectl get rolebinding,clusterrolebinding,role,clusterrole --all-namespaces -o jsonpath='{range .items[?(@.subjects[0].name=="testsix")]}[{.roleRef.kind},{.roleRef.name}]{end}'
[No output returns]
有人能给我指出正确的方向吗?顺便说一句,我已经验证了使用从证书生成的用户不会发生同样的问题-它只会发生在服务帐户上。
谢谢!
2条答案
按热度按时间thigvfpy1#
gojuced72#
只需创建另一个具有不同名称crb