OpenShift - Resolve error: rolebinding found for "Role", not "ClusterRole"

by
Jeremy Canfield |
Updated: January 30 2024
| OpenShift articles
Let's say you are attempting to add a User, Group or Service Account to a Role Binding and something like this is being returned. In this example, the error is returned when attempting to add Group "my-group" to Role Binding "my-role-binding".
~]$ oc adm policy add-role-to-group basic-user my-group --rolebinding-name my-role-binding
error: rolebinding my-role-binding found for "Role", not "ClusterRole"
Notice in this example that an attempt was made to add Group "my-group" to Role Binding "my-role-binding" with role basic-user. It is probably the case that Role basic-user does not exist in the namespace. basic-user is a Cluster Role, not a Role within the current namespace.
~]$ oc get roles
NAME CREATED AT
my-role 2023-07-07T15:42:28Z
Thus the solution is to use add-cluster-role-to-group
~]$ oc adm policy add-cluster-role-to-group basic-user my-group --rolebinding-name my-role-binding
clusterrole.rbac.authorization.k8s.io/basic-user added: "my-group"
Did you find this article helpful?
If so, consider buying me a coffee over at