A RoleBinding is used to bind a Role or ClusterRole to a list of users or service accounts. If a ClusterRole is bound with a RoleBinding instead of a ClusterRoleBinding, it'll be only granted the permissions within the namespace that RoleBinding specified. The following is an example of RoleBinding spec:
# cat 8-5-2_rolebinding_user.yml kind: RoleBindingapiVersion: rbac.authorization.k8s.io/v1beta1metadata: name: devops-role-binding namespace: project1subjects:- kind: User name: linda apiGroup: [""]roleRef: kind: Role name: devops-role apiGroup: [""]
In this example, we bind a Role with a user by roleRef. Kubernetes supports different kind of roleRef; we could replace the kind from Role to ClusterRole