Role-based access control (RBAC) lets you grant permissions to Kubernetes resources by binding them to roles. You can then assign these roles to users to control their access and minimize security risks. This topic describes how to configure Kubernetes RBAC permissions for a RAM user or a RAM role.
Overview
|
Parameter |
Description |
|
Default permissions |
|
|
Authorization methods |
Note
Before you begin, make sure the target RAM user or RAM role has been granted read-only RAM permissions for the specified cluster in the RAM console. |
|
Authorization mode |
You can grant permissions to RAM users or RAM roles individually or in batches. |
Due to Alibaba Cloud RAM security restrictions, when you modify permissions for a RAM user or RAM role in the ACS console, you must also manually grant the permissions in the RAM console by following the on-screen instructions.
Grant RBAC permissions to RAM users or roles
-
Log on to the ACS console. In the left navigation pane, choose Authorizations.
-
On the Authorizations page, configure permissions for a RAM user or RAM role.
ImportantACS clusters are a type of ACK serverless cluster. If you have already granted a RAM user or RAM role RBAC permissions for "All Clusters" in the ACK console, those permissions automatically apply to ACS clusters. You cannot grant separate permissions for ACS clusters from the ACS console; they inherit the "All Clusters" policy.
-
To authorize a RAM user:
On the RAM Users tab, find the target RAM user and click Modify Permissions in the Actions column, which opens the Permission Management panel.
-
To authorize a RAM role:
Click the RAM Roles tab. Enter the RAM Role Name and click Modify Permissions to open the Permission Management panel.
-
-
In the Permission Management panel, click + Add Permissions. Configure the permission settings for the target RAM user or RAM role at the Clusters and Namespace levels, select a predefined role, and then click Submit.
Predefined role
In-cluster RBAC permissions
Administrator
Read and write permissions for all resources across all namespaces.
O&M Engineer
Read and write permissions for Kubernetes resources visible in the console across all namespaces, and read-only permissions for persistent volumes, namespaces, and quotas.
Developer
Read and write permissions for Kubernetes resources visible in the console within all or selected namespaces.
Restricted User
Read-only permissions for Kubernetes resources visible in the console within all or selected namespaces.
Custom
The selected cluster role determines the permissions. To avoid granting unintended permissions, review the permissions of the cluster role before assigning it to a RAM user or RAM role. For instructions on how to view custom permissions, expand the section below.
ImportantA RAM user or RAM role with the cluster-admin permission has super-administrator privileges within the cluster, equivalent to an Alibaba Cloud account. This role provides unrestricted access to all cluster resources. Assign this role with extreme caution.
-
After the configuration is complete, you can log on to the ACS console as the target RAM user or RAM role to perform operations.
Note-
Ensure that the RAM user or RAM role has the required RAM permissions for the cluster and is also granted the RBAC Administrator or cluster-admin role. For more information, see Grant RAM permissions to a RAM user or RAM role.
-
ACS provides four standard predefined roles: Administrator, O&M Engineer, Developer, and Restricted User. These roles meet most access control requirements. If you need to define more granular permissions, use the Custom role feature.
-
You can assign one predefined role and multiple custom roles to a RAM user or RAM role for a specific cluster or namespace.
-
If you want to grant permissions for all clusters at once so that new clusters automatically inherit these permissions, select All Clusters from the Clusters drop-down list.
-
Delegate RBAC authorization to RAM users or roles
To delegate this capability, an Alibaba Cloud account or a RAM user with the cluster-wide Administrator role must grant the necessary RAM and RBAC permissions to the intended user or role.
RAM permissions
You must grant the RAM user or RAM role a RAM policy that includes the following permissions:
-
View other RAM principals.
-
Attach a RAM policy.
-
View cluster information.
-
View RBAC permission configurations.
-
Grant RBAC permissions.
-
Log on to the RAM console and grant the required RAM permissions to the RAM user or RAM role by using a policy similar to the following example. For more information, see Grant RAM permissions to a RAM user or RAM role.
ImportantReplace
xxxxxxwith the name of the RAM policy to attach. Using an asterisk (*) allows the RAM user or RAM role to attach any RAM policy. Setting "Resource": "*" grants permission to perform the specified actions on all resources under your account. The cs:* action applies to all ACK clusters except for ACS clusters. Grant these permissions with caution.{ "Statement": [{ "Action": [ "ram:Get*", "ram:List*", "cs:DescribeClustersV1", "cs:GrantPermission" ], "Resource": "*", "Effect": "Allow" }, { "Action": [ "ram:AttachPolicyToUser", "ram:AttachPolicy" ], "Effect": "Allow", "Resource": [ "acs:ram:*:*:policy/xxxxxx", "acs:*:*:*:user/*" ] } ], "Version": "1" } -
After you grant the permissions, the RAM user or RAM role can grant RAM permissions to other RAM users or RAM roles within the scope of the specified policy.
RBAC permissions
-
After you grant the required RAM permissions, you must also assign the Administrator predefined role or the cluster-admin custom role to the RAM user or RAM role for the target cluster or namespace. For more information, see Set an authorization subject as a permission administrator for in-cluster applications.
Set RAM users or roles as permission administrators
If it is inconvenient to use an Alibaba Cloud account to grant permissions, you can set a RAM user or RAM role as a permission administrator. You can then use this permission administrator to perform authorization tasks.
-
Log on to the RAM console and locate the target RAM user or RAM role.
-
RAM user
In the left-side navigation pane, choose . In the user list, find the target user and click Attach Policy in the Actions column.
-
RAM role
In the left-side navigation pane, choose . In the role list, find the target role and click Attach Policy in the Actions column.
-
-
In the Attach Policy dialog box, click the search box in the Policy section. Search for the
AliyunRAMFullAccessandAliyunACCFullAccesssystem policies by name, and then select them. The selected policies are added to the Selected Policy area on the right. Click OK, and then close the dialog box to complete the authorization. -
Log on to the ACS console and grant the Administrator predefined role to the RAM user or RAM role for all clusters. For more information, see Grant RBAC permissions to a RAM user or RAM role.
-
After you complete these steps, the RAM user or RAM role becomes a permission administrator and can grant RAM and RBAC permissions to other RAM users and RAM roles.
Permission error codes
If an operation in the console or an API call fails due to insufficient RBAC permissions, the system returns a corresponding error code. The following table lists the required cluster RBAC permissions for common error codes.
|
Error code or message |
Required RBAC permission |
|
ForbiddenCheckControlPlaneLog |
Administrator or O&M Engineer |
|
ForbiddenHelmUsage |
Administrator |
|
ForbiddenRotateCert |
Administrator |
|
ForbiddenQueryClusterNamespace |
Administrator, O&M Engineer, Developer, or Restricted User |