Use ack-ram-authenticator for secure RAM webhook authentication on ACK managed cluster API server requests. Map RAM identities to RBAC and distinguish SSO users who assume the same role in audit logs. This topic describes the webhook authentication method and usage workflow.
Prerequisites
An ACK managed cluster (version 1.24.6-aliyun.1 or later) is created. See Create an ACK managed cluster.
Usage notes
Installing or uninstalling
ack-ram-authenticatorrestarts the API server and disconnects long-lived connections. Schedule during off-peak hours.Webhook authentication does not block API server access with KubeConfig from
DescribeClusterUserKubeconfig.ack-ram-authenticatoris also supported on ACK Serverless Clusters.
How ack-ram-authenticator works
ack-ram-authenticator is an authentication add-on for ACK managed clusters. It uses Kubernetes Webhook Token Authentication to authenticate API server requests with Alibaba Cloud RAM and maps RAM identities to RBAC permissions as CRDs.
When a user assumes an Alibaba Cloud SSO role to access an ACK managed cluster API server, ack-ram-authenticator passes the session name for that identity to the API server. This lets the API server authenticate requests from different users who assume the same role.
The following figure shows how webhook authentication works in an ACK managed cluster with ack-ram-authenticator installed.

-
When you use a tool such as kubectl to authenticate to the API server, the kubectl client runs the
execcommand in the kubeconfig file and calls ack-ram-tool to generate a signed STS token URL. -
The kubectl client sends the authentication webhook to the API server, which routes it to ack-ram-authenticator.
-
ack-ram-authenticator calls the GetCallerIdentity operation to obtain the caller identity from the token URL, then matches it against the identity mappings defined in RAMIdentityMapping configurations.
-
The API server verifies the RBAC permissions of the matched RAM user or user group and returns the authentication result to the kubectl client.
Benefits
Compared with default X.509 certificate authentication in ACK, webhook authentication with ack-ram-authenticator offers:
Enterprise SSO integration with flexible, manageable data plane RBAC authorization.
In SSO scenarios, API server audit logs include enterprise Identity Provider (IdP) identity information to audit actions from different IdP users who assume the same role.
When a departing employee's RAM user or RAM role is deleted, their cluster RBAC permissions are automatically revoked.
Step 1: Install ack-ram-authenticator
Install the ack-ram-authenticator server-side add-on to enable RAM webhook authentication with the cluster API server.
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of your cluster. In the left navigation pane, click Components and Add-ons.
On the Add-ons page, click the Security tab, find the
ack-ram-authenticatoradd-on, and click Install in the lower-right corner of the card. In the Parameters dialog box that appears, select theEnableNonBootstrapMappingoption, and then click OK.
Step 2: Install the ack-ram-tool client
On your local machine, ack-ram-tool generates a KubeConfig file with credentials for a cluster.
Download ack-ram-tool for your OS and architecture.
Grant execute permissions to the client:
chmod +x ./ack-ram-toolCopy ack-ram-tool to a directory in your system
PATH:mkdir -p $HOME/bin && cp ./ack-ram-tool $HOME/bin/ack-ram-tool && export PATH=$HOME/bin:$PATH(Optional) For Bash, persist the
PATHconfiguration in~/.bash_profile:echo 'export PATH=$HOME/bin:$PATH' >> ~/.bash_profileVerify the installation. The command returns the client version.
ack-ram-tool version
Step 3: Configure Alibaba Cloud credentials
RAM users and SSO users can configure Alibaba Cloud credentials using one of the following methods.
If credential-related environment variables are set, ack-ram-tool uses them by default. Add --ignore-env-credentials to your ack-ram-tool commands to override. Supported environment variables for ack-ram-tool: Credentials.
RAM users
ack-ram-tool uses locally configured Alibaba Cloud credentials to authenticate with RAM.
See Alibaba Cloud CLI to configure access credentials.
SSO users
SSO users use acs-sso, the CloudSSO CLI tool, to log on and obtain credentials. See Use the CLI to log on to CloudSSO and access Alibaba Cloud resources for acs-sso. The Alibaba Cloud CLI external mode obtains credentials by running an external command. Configure automated CloudSSO logon and credential retrieval:
aliyun configure --mode External --profile sso
Configuring profile 'sso' in 'External' authenticate mode...
Process Command [acs-sso login --profile sso]:
Default Region Id [cn-shanghai]:
Default Output Format [json]: json (Only support json)
Default Language [zh|en] en:
Saving profile[sso] ...Done.
Configure Done!!!
..............888888888888888888888 ........=8888888888888888888D=..............
...........88888888888888888888888 ..........D8888888888888888888888I...........
.........,8888888888888ZI: ...........................=Z88D8888888888D..........
.........+88888888 ..........................................88888888D..........
.........+88888888 .......Welcome to use Alibaba Cloud.......O8888888D..........
.........+88888888 ............. ************* ..............O8888888D..........
.........+88888888 .... Command Line Interface(Reloaded) ....O8888888D..........
.........+88888888...........................................88888888D..........
..........D888888888888DO+. ..........................?ND888888888888D..........
...........O8888888888888888888888...........D8888888888888888888888=...........
............ .:D8888888888888888888.........78888888888888888888O ..............Step 4: Generate a KubeConfig file
Generate a KubeConfig file. Command details: get-kubeconfig.
ack-ram-tool credential-plugin get-kubeconfig --cluster-id $cluster_id --mode ram-authenticator-tokenMerge or replace your existing KubeConfig with the generated file. See Organizing Cluster Access Using kubeconfig Files.
Step 5: Map RAM identities to RBAC permissions
Select the EnableNonBootstrapMapping option during installation. Otherwise, the mappings below do not take effect.
After you install ack-ram-authenticator, the cluster creates a RAMIdentityMapping CRD that maps RAM identities to Kubernetes user models. As a cluster administrator, map a RAM user or RAM role to a Kubernetes user with RBAC permissions.
Create a configuration template file named
auth.yamlwith this content:cat >auth.yaml <<EOF --- apiVersion: ramauthenticator.k8s.alibabacloud/v1alpha1 kind: RAMIdentityMapping metadata: name: tester spec: arn: '<ARN>' username: tester groups: - system:users EOFEach RAMIdentityMapping instance maps one RAM ARN to a
usernameandgroups. Create one instance per mapping.Replace
<ARN>with the target RAM user or RAM role ARN. The following table lists ARN formats by account type.Account type
ARN format
Example
Alibaba Cloud account
acs:ram::<root_uid>:root<root_uid>is theAlibaba Cloud AccountID.acs:ram::123456789012****:rootRAM user
acs:ram::<root_uid>:user/<user_name><root_uid>is the Alibaba Cloud Account ID and<user_name>is the RAM user name.acs:ram::123456789012****:user/testuserRAM role
acs:ram::<root_uid>:role/<role_name><root_uid>is theAlibaba Cloud AccountID and<role_name>is the RAM role name. See View the information about a RAM role to view a RAM role ARN.acs:ram::123456789012****:role/testrole
Create the
RAMIdentityMappinginstance:kubectl apply -f auth.yamlConfigure RBAC permissions for the cluster. Create custom RBAC roles and bindings as needed.
Example RBAC binding:
cat >binding.yaml <<EOF --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: tester-clusterrolebinding roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: cs:ops subjects: - apiGroup: rbac.authorization.k8s.io kind: User name: tester EOF kubectl apply -f binding.yaml
Step 6: Send requests with KubeConfig
Use the KubeConfig file from Step 4 to send a request to the API server and verify success within the configured permissions.
kubectl get nsExpected output:
NAME STATUS AGE
arms-prom Active 4h48m
default Active 4h50m
kube-node-lease Active 4h50m
kube-public Active 4h50m
kube-system Active 4h50m