Этого можно добиться с помощью следующих правил:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: role-grantor
rules:
- apiGroups: ["rbac.authorization.k8s.io"]
resources: ["rolebindings"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
- apiGroups: ["rbac.authorization.k8s.io"]
resources: ["roles"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: role-grantor-binding
namespace: office
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: role-grantor
subjects:
- apiGroup: rbac.authorization.k8s.io
kind: User
name: employee
Я проверил его в своей лаборатории, и он работает по вашему желанию:
$ kubectl --context=employee-context get role
NAME AGE
deployment-manager 15m
role-binder 12m
$ kubectl --context=employee-context get rolebindings
NAME AGE
deployment-manager-binding 15m
role-grantor-binding 3m37s
$ kubectl --context=employee-context get clusterrolebindings
Error from server (Forbidden): clusterrolebindings.rbac.authorization.k8s.io is forbidden: User "employee" cannot list resource "clusterrolebindings" in API group "rbac.authorization.k8s.io" at the cluster scope
Подробнее об этом можно прочитать конкретно в документации .