This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.5.6. Adding roles to users
You can use the oc adm
administrator CLI to manage the roles and bindings.
Binding, or adding, a role to users or groups gives the user or group the access that is granted by the role. You can add and remove roles to and from users and groups using oc adm policy
commands.
You can bind any of the default cluster roles to local users or groups in your project.
Procedure
Add a role to a user in a specific project:
oc adm policy add-role-to-user <role> <user> -n <project>
$ oc adm policy add-role-to-user <role> <user> -n <project>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, you can add the
admin
role to thealice
user injoe
project by running:oc adm policy add-role-to-user admin alice -n joe
$ oc adm policy add-role-to-user admin alice -n joe
Copy to Clipboard Copied! Toggle word wrap Toggle overflow View the local role bindings and verify the addition in the output:
oc describe rolebinding.rbac -n <project>
$ oc describe rolebinding.rbac -n <project>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, to view the local role bindings for the
joe
project:oc describe rolebinding.rbac -n joe
$ oc describe rolebinding.rbac -n joe
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The
alice
user has been added to theadmins
RoleBinding
.