Architecture Overview
Rancher’s RBAC system operates at three distinct levels:- Global Level - Permissions that apply across the entire Rancher installation
- Cluster Level - Permissions scoped to a specific Kubernetes cluster
- Project Level - Permissions scoped to a project (group of namespaces)
Core Components
RoleTemplate
RoleTemplates are the building blocks of Rancher’s authorization system. They define a set of Kubernetes RBAC PolicyRules that can be applied at either the cluster or project level. Key Fields:displayName- Human-readable name shown in the UIrules- Array of Kubernetes PolicyRulescontext- Either “cluster” or “project” to indicate scopebuiltin- If true, the RoleTemplate is managed by Rancher and immutableexternal- If true, rules are sourced from an existing ClusterRoleroleTemplateNames- List of other RoleTemplates to inherit fromlocked- If true, new bindings cannot use this RoleTemplateclusterCreatorDefault- Auto-assigned to cluster creatorsprojectCreatorDefault- Auto-assigned to project creators
pkg/apis/management.cattle.io/v3/authz_types.go:301-372
GlobalRole
GlobalRoles define permissions that apply to the local cluster and can optionally grant permissions across all downstream clusters. Key Fields:rules- PolicyRules applied to the local cluster onlyinheritedClusterRoles- RoleTemplate names granted in every downstream clusternamespacedRules- Rules active in specific namespaces of the local clusterinheritedFleetWorkspacePermissions- Permissions granted in all Fleet workspacesnewUserDefault- If true, automatically bound to new usersbuiltin- Indicates Rancher-managed roles that are immutable
pkg/apis/management.cattle.io/v3/authz_types.go:142-190
Role Bindings
Rancher uses three types of role bindings:GlobalRoleBinding
Binds a subject (user or group) to a GlobalRole. Fields:userName- User to bind (immutable)groupPrincipalName- Group principal to bind (immutable)globalRoleName- Target GlobalRole (immutable)
pkg/apis/management.cattle.io/v3/authz_types.go:230-257
ClusterRoleTemplateBinding (CRTB)
Binds a subject to a RoleTemplate within a specific cluster. Fields:userName/userPrincipalName- User subject (immutable)groupName/groupPrincipalName- Group subject (immutable)clusterName- Target cluster (immutable)roleTemplateName- RoleTemplate to apply (immutable)
pkg/apis/management.cattle.io/v3/authz_types.go:428-465
ProjectRoleTemplateBinding (PRTB)
Binds a subject to a RoleTemplate within a specific project. Fields:userName/userPrincipalName- User subject (immutable)groupName/groupPrincipalName- Group subject (immutable)projectName- Target project (immutable)roleTemplateName- RoleTemplate to apply (immutable)
pkg/apis/management.cattle.io/v3/authz_types.go:378-412
Role Hierarchy
Inheritance Model
RoleTemplates support inheritance through theroleTemplateNames field. A RoleTemplate can reference other RoleTemplates, inheriting all their rules. This creates a directed graph of permissions.
Circular Dependency Protection:
- Soft limit: 100 recursive function calls (warning logged)
- Hard limit: 500 recursive function calls (error returned)
pkg/controllers/management/auth/manager.go:812-826
Built-in Role Examples
Frompkg/data/management/role_data.go, Rancher provides several built-in roles:
Cluster Roles:
cluster-admin- Kubernetes default cluster admincluster-owner- Full cluster control with ownership verbcluster-member- Read access to cluster resources, can create projectsprojects-create- Can create new projectsprojects-view- Can view all projects and their resourcesnodes-manage- Manage nodes and node poolsstorage-manage- Manage persistent volumes and storage classes
admin- Kubernetes default adminproject-owner- Full project control with ownership verbproject-member- Can manage workloads and resourcesread-only- Read-only access to project resourcesedit/view- Kubernetes default roles
Permission Model
Policy Rules
All permissions ultimately resolve to Kubernetes RBAC PolicyRules:Special Verbs
Rancher introduces custom verbs beyond standard Kubernetes RBAC:own- Indicates ownership of a cluster or project resourceupdatepsa- Allows updating Pod Security Admission settings
pkg/controllers/management/auth/manager.go:868-879
Management Plane Resources
Certain resources (projects, machines, role bindings, etc.) exist in the management plane but are scoped to clusters or projects. Rancher creates special Roles and RoleBindings in backing namespaces to authorize access. Key resources requiring management plane authorization:projects- Project custom resourcesprojectroletemplatebindings- Project member bindingsclusterroletemplatebindings- Cluster member bindingsmachines- Node machine resourcesclusterevents- Cluster-scoped events
pkg/controllers/management/auth/manager.go:390-461
Role Binding Lifecycle
Membership Bindings
When a CRTB or PRTB is created, Rancher automatically creates “membership” bindings that grant the subject access to the cluster or project custom resource itself:- Cluster Membership - Creates ClusterRoleBinding for cluster resource access
- Project Membership - Creates RoleBinding in project namespace for project resource access
- Cluster:
pkg/controllers/management/auth/manager.go:124-204 - Project:
pkg/controllers/management/auth/manager.go:206-285
Binding Reconciliation
When a CRTB/PRTB is deleted or modified, Rancher reconciles membership bindings:- If no other bindings reference the same role and subject, the binding is deleted
- If other bindings exist, only the owner label is removed
pkg/controllers/management/auth/manager.go:287-362
Access Types
The RBAC system defines three standard access levels:pkg/controllers/management/rbac/rbac.go:19-22
Status Tracking
Both GlobalRoleBindings and ClusterRoleTemplateBindings track their status separately for local and remote (downstream) clusters:observedGenerationLocal- Generation observed by local controllerobservedGenerationRemote- Generation observed by remote controllersummaryLocal/summaryRemote- “Complete” or “Error”localConditions/remoteConditions- Detailed status conditions
Related Resources
- Global Roles - Global-level permissions
- Cluster Roles - Cluster-level permissions
- Project Roles - Project-level permissions