If your Serverless App Engine (SAE) application and Container Registry (ACR) instance are in different Alibaba Cloud accounts, first ensure network connectivity. Then, configure authorization to access the ACR instance. Finally, provide the image repository address to deploy the application.
Prerequisites
Ensure network connectivity for SAE and ACR
You must either establish cross-VPC connectivity or enable a public NAT gateway for your application's Virtual Private Cloud (VPC). For ACR Enterprise Edition instances, you must also add the CIDR block of the SAE application's VPC or the Elastic IP Address (EIP) bound to the NAT gateway to the ACR instance's whitelist.
Configure ACR access authorization
You can use either Static Username and Password or a RAM Role.
Static username and password
Create a Secret to store the username and password for the image repository. On the Namespace page, select a region, click the target namespace, choose Secret in the left-side navigation pane, and then click Create.
-
Set Type to Private Image Repository Logon Key.
-
In the Image Repository Address field, enter the public domain of the ACR instance. For example,
registry.cn-xx.aliyuncs.comfor Container Registry Personal Edition orxx-registry.cn-xx.cr.aliyuncs.comfor ACR Enterprise Edition. Enter the Username and Password to log on to the image repository.
RAM role
SAE can pull images from an ACR instance in another account by assuming a RAM role. For example, an application in Account A can assume a RAM role in Account B to pull images from an ACR instance owned by Account B.
-
Create a RAM role: Use Account B to create a RAM role for Account A. For more information, see Create a RAM role for a trusted Alibaba Cloud account.
-
Configure an access policy: Create a custom policy or modify a custom policy to include the following statements to allow operations on private images.
{ "Version": "1", "Statement": [ { "Effect": "Allow", "Action": [ "cr:GetAuthorizationToken", "cr:ListInstanceEndpoint", "cr:PullRepository", "cr:GetRepository", "cr:ListRepositoryTag" ], "Resource": "*" } ] } -
Grant permissions to the RAM role: Grant the access policy from Step 2 to the RAM role from Step 1. For more information, see Manage RAM role permissions.
-
Modify the trusted entity of the RAM role: Change the trusted entity of the RAM role from Step 1 to the SAE service account by modifying the trust policy. For more information, see Modify the trust policy of a RAM role.
Before
After
{ "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "RAM": [ "acs:ram::123456789012****:root" ] } } ], "Version": "1" }This RAM role can be assumed by any authorized RAM user or RAM role under the Alibaba Cloud account (AccountID=123456789012****).
{ "Statement": [ { "Action": "sts:AssumeRole", "Effect": "Allow", "Principal": { "Service": [ "123456789012****@sae.aliyuncs.com" ] } } ], "Version": "1" }This RAM role can only be assumed by the SAE service account (123456789012****@sae.aliyuncs.com) for the Alibaba Cloud account (AccountID=123456789012****).
NoteIn this example,
Servicerefers to the service that pulls the image. -
Copy the ARN: On the Basic Information page of the RAM role, copy the ARN. You will need this value for the acrAssumeRoleArn field when deploying the application.
Procedure
-
On the SAE Application List page, select the target region and namespace in the top navigation bar, and then click Create Application.
-
Select an application edition.
ImportantThe Lightweight Edition and Professional Edition are currently in an invite-only beta phase. For users not participating in the beta test, applications are created as the Standard Edition by default.
-
Lightweight Edition: Provides the minimum feature set required to run an application. It does not support the Application Monitoring and Microservices Governance features.
-
Standard Edition: Includes the Basic Application Monitoring feature. The Advanced Application Monitoring and Microservices Governance features must be enabled and purchased separately.
-
Professional Edition: Includes the Advanced Application Monitoring and Microservices Governance features, which do not need to be enabled or purchased separately.
-
-
On the Create Application page, specify an Application Name and configure the following parameters.
-
Select the namespace type for the application. A namespace is equivalent to a Kubernetes namespace and can be used to isolate resources in different environments. You cannot change the namespace of an application after it is created. Plan accordingly.
-
System Created: Use the default namespace, vSwitch, and security group created by the system in the current region.
-
Existing Namespace: Select a namespace, vSwitch, and security group that you created in advance.
-
-
Set Application Deployment Method to Select Image Deployment, and then click Specify Image on the right. On the Private Images of Other Alibaba Cloud Account tab, configure the following parameters.
-
Select your ACR edition, and then choose an authorization method. For ACR Enterprise Edition, you must also enter the Enterprise Edition Instance ID.
-
Static Username and Password: Select the Secret for Username and Password of Image Repository that you created earlier.
-
RAM Role: Enter the acrAssumeRoleArn that you copied earlier.
-
-
Enter the Complete Image Repository Address in the format
<image-repository-address>:<image-tag>. For example:registry.cn-xx.aliyuncs.com/xx/xx:1.0for Container Registry Personal Edition, orxx-registry.cn-xx.cr.aliyuncs.com/xx/xx:1.0for ACR Enterprise Edition.Note: Use the public or private image repository address that corresponds to your network configuration. -
For ACR Enterprise Edition, you can enable image acceleration to speed up application startup.
-
-
In the Capacity Settings section, set Resource Type, Single Instance Type, and Instances.
-
-
(Optional) Click Next: Advanced Settings to configure desired features.
-
Click Create Application with One Click or Create Application.
-
Creating the application takes about 1 to 2 minutes. You can view change records to verify that the deployment was successful. If the deployment fails, no application instance is created. You can troubleshoot the issue based on the error message in Change Details.
-
You can view the created application on the page. To change the application configuration after deployment, click the target application to go to its details page. Then, click Deploy Application or Modify Application Configurations at the top. The application automatically restarts to apply the new configuration. Perform this operation during off-peak hours.
-
You can log on to an application instance by using Webshell and interact with the instance by using console commands.
-
After you create an application, you can manually adjust the number of instances and the instance specification, or automatically adjust the number of instances by configuring an auto scaling policy. You can also reduce costs by enabling idle mode.
-