RoleBinding 和 ClusterRoleBinding 中的 Kubernetes RBAC apiGroup 字段

Kubernetes RBAC apiGroup field in RoleBinding and ClusterRoleBinding

为什么我们要在这个定义中一遍又一遍地写apiGroup键,如果每次都一样的话:

kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
 name: web-rw-deployment
 namespace: some-web-app-ns
subjects:
- kind: User
 name: "joesmith@example.com"
 apiGroup: rbac.authorization.k8s.io
- kind: Group
 name: "webdevs"
 apiGroup: rbac.authorization.k8s.io
roleRef:
 kind: Role
 name: web-rw-deployment
 apiGroup: rbac.authorization.k8s.io

这使得 yaml 过于多余,有什么办法可以解决这个问题。我们可以跳过这个键吗?或者我们可以在全球某个地方声明它吗?

好问题。我能想到的基本原理是,将来可能会支持不同的 API,例如,rbacv2.authorization.k8s.io,出于兼容性原因,您不希望将引用和主题限制为仅一个。

我对此的看法是,如果 RoleBinding 除了 'subjects' 之外还有另一个可选的全局字段,称为 'bindingApigroup' 之类的东西,那就太好了。随便开一个issue:kind/feature,sig/authand/orsig/api-machinery.

此外,sig-auth设计方案中可能还有更多rationale/details。