How to Create Custom Platform Role
TOC
1. Overview2. Core Concepts3. Technical Changes4. Supported Configuration Methods5. Configuration5.1 RoleTemplate YAMLFunctionResource method (supported until v4.5)ClusterRole aggregation method (v4.2+)customRules method5.2 Get ClusterRoles generated from a RoleTemplate6. Copy & Trim (Examples)6.1 Trim a system RoleTemplate YAML6.2 Trim namespace-developer-system into an auditor role1. Overview
This document explains the core concepts of custom roles and how to configure a RoleTemplate.
2. Core Concepts
- RoleTemplate: Custom role template. It defines role semantics and permission sets, and is converted by the controller into ClusterRoles.
- FunctionResource: An abstraction of K8s resources used by product features; referenced by
functionResourceRefin RoleTemplate. - ClusterRole: RBAC rule set; can be aggregated into system roles via labels.
- UserBinding: Binding between users and roles/scopes; the controller generates RoleBinding/ClusterRoleBinding based on UserBinding for final authorization.
- The value of
functionResourceRefcomes from FunctionResourcemetadata.name. - Display names are typically in
metadata.annotations, which you can use to map to UI modules.
3. Technical Changes
Starting from ACP v4.3, feature permissions are gradually migrated from FunctionResource to native K8s ClusterRole management. RoleTemplate module permissions will be aggregated into system roles via ClusterRole labels. FunctionResource-based management will be retired in v4.5.
4. Supported Configuration Methods
- FunctionResource method: Select permissions by product modules and control verbs at fine granularity.
- ClusterRole aggregation method (aggregationRules): Centralized aggregation via ClusterRole labels; recommended for v4.2+.
- customRules: Configure permissions using native K8s RBAC syntax; same rule format as ClusterRole
rules.
5. Configuration
5.1 RoleTemplate YAML
FunctionResource method (supported until v4.5)
FunctionResource example:
ClusterRole aggregation method (v4.2+)
ClusterRole with aggregation labels:
customRules method
RoleTemplate field reference (with ranges):
spec.rules and spec.aggregationRules are mutually exclusive.
System labels for matchLabels
System role aggregation labels:
rbac.cpaas.io/aggregate-to-platform-admin: "true"rbac.cpaas.io/aggregate-to-platform-auditor: "true"rbac.cpaas.io/aggregate-to-cluster-admin: "true"rbac.cpaas.io/aggregate-to-project-admin: "true"rbac.cpaas.io/aggregate-to-namespace-admin: "true"rbac.cpaas.io/aggregate-to-namespace-developer: "true"rbac.cpaas.io/aggregate-to-basic-user: "true"
Scope aggregation labels:
rbac.cpaas.io/aggregate-to-scope-cluster: "true"rbac.cpaas.io/aggregate-to-scope-project-ns: "true"rbac.cpaas.io/aggregate-to-scope-business-ns: "true"rbac.cpaas.io/aggregate-to-scope-system-ns: "true"rbac.cpaas.io/aggregate-to-scope-kube-public: "true"
Custom labels are also supported for aggregation.
FunctionResource field reference:
acp-namespace-resource-manage is not allowed in custom roles.
5.2 Get ClusterRoles generated from a RoleTemplate
Query ClusterRoles generated by a RoleTemplate using labels:
6. Copy & Trim (Examples)
For custom roles, it is recommended to copy a built-in system template and trim it to avoid missing module permissions.
6.1 Trim a system RoleTemplate YAML
Steps:
- Keep the required FunctionResources.
- Reduce verbs to read-only (get/list/watch).
- Remove unused modules.
Role example: developer auditor without secret permissions
- In custom roles, do not configure Namespace Resource Management (FunctionResource:
acp-namespace-resource-manage). - Remove User Secret Dictionary (FunctionResource:
acp-user-secret). - Set all verbs to get/list/watch.
Example YAML:
6.2 Trim namespace-developer-system into an auditor role
Approach:
- Keep the scope structure (cluster / project-ns / business-ns / system-ns / kube-public).
- Replace aggregation labels with auditor labels (requires labeled ClusterRoles).
Example (excerpt):
aggregate-to-namespace-auditor must match labels on existing ClusterRoles. If not, create a read-only ClusterRole and add the label first.