Roles define permissions within a specific namespace. Unlike ClusterRoles, Roles can only grant access to resources within the namespace where they are created.Documentation Index
Fetch the complete documentation index at: https://docs.shiftlabs.dev/llms.txt
Use this file to discover all available pages before exploring further.
Key Concepts
Role
Rules
Namespace
System Role
system: or containing kubernetes.io).Required Permissions
| Action | Permission |
|---|---|
| View Roles | iam:project:infrastructure:kubernetes:read |
| Create Role | iam:project:infrastructure:kubernetes:write |
| Edit Role | iam:project:infrastructure:kubernetes:write |
| Delete Role | iam:project:infrastructure:kubernetes:delete |
Role Types
| Type | Description |
|---|---|
| System | Built-in Kubernetes roles (should not be modified) |
| Custom | User-created Roles |
How to View Roles
How to View Role Details
How to Create a Role
Write YAML
metadata.namespace- Target namespacerules- Array of permission rules
How to Edit a Role
How to Delete a Role
Rule Structure
Each rule in a Role specifies:| Field | Description |
|---|---|
| apiGroups | API groups containing the resources (empty string for core API) |
| resources | Resource types to grant access to |
| verbs | Actions allowed on the resources |
| resourceNames | Optional: specific resource names to restrict access |
Common Verbs
| Verb | Description |
|---|---|
get | Read a single resource |
list | List resources |
watch | Watch for changes |
create | Create new resources |
update | Update existing resources |
patch | Partially update resources |
delete | Delete resources |
deletecollection | Delete multiple resources |
* | All verbs (full access) |
Example Roles
Pod Reader
Deployment Manager
ConfigMap and Secret Manager
Specific Resource Access
Full Namespace Admin
Role vs ClusterRole
| Aspect | Role | ClusterRole |
|---|---|---|
| Scope | Single namespace | Cluster-wide |
| Can access | Namespace resources only | All resources including cluster-scoped |
| Use case | Team/app specific permissions | Admin, operators, cross-namespace access |
| Binding | RoleBinding only | RoleBinding or ClusterRoleBinding |
Troubleshooting
User cannot access namespace resources
User cannot access namespace resources
- Verify a RoleBinding exists binding the user to a Role
- Check the Role has the necessary rules
- Verify the Role and RoleBinding are in the same namespace
- Use
kubectl auth can-i --as=<user> -n <namespace>to test permissions
Cannot delete Role
Cannot delete Role
- System roles cannot be deleted
- Verify you have delete permission
- Check for finalizers blocking deletion
Permission changes not taking effect
Permission changes not taking effect
- RBAC changes are immediate, no restart needed
- Verify the RoleBinding references the correct Role
- Check if there are multiple Roles/bindings affecting the user
- Clear any client-side caching
Role in wrong namespace
Role in wrong namespace
- Roles only grant permissions in their namespace
- Delete and recreate the Role in the correct namespace
- Or use a ClusterRole with RoleBinding for reusability
Cannot access resources in other namespaces
Cannot access resources in other namespaces
- Roles are namespace-scoped
- Create separate Roles in each namespace, or
- Use ClusterRole with RoleBinding per namespace, or
- Use ClusterRole with ClusterRoleBinding for all namespaces
FAQ
What is the difference between Role and ClusterRole?
What is the difference between Role and ClusterRole?
Can a Role grant access to cluster-scoped resources?
Can a Role grant access to cluster-scoped resources?
How do I reuse a Role across namespaces?
How do I reuse a Role across namespaces?
- Create identical Roles in each namespace
- Use a ClusterRole and bind it with RoleBindings in each namespace (recommended)
Can I bind a ClusterRole with a RoleBinding?
Can I bind a ClusterRole with a RoleBinding?
What happens if I delete a namespace with Roles?
What happens if I delete a namespace with Roles?
How do I check what permissions a Role grants?
How do I check what permissions a Role grants?
kubectl describe role <name> -n <namespace> or click on the Role in the UI to see the complete rule list.Can a Role grant permissions to resources it doesn't have?
Can a Role grant permissions to resources it doesn't have?
Should I create Roles or use built-in ClusterRoles?
Should I create Roles or use built-in ClusterRoles?
admin, edit, view) with RoleBindings for common scenarios. Create custom Roles when you need fine-grained, namespace-specific permissions that don’t match built-in roles.