Update image in a scaling configuration
Images in scaling configurations often require updates as your application evolves. You can update images manually for full control, or automatically to streamline frequent releases.
Background
-
This topic applies only to scaling groups that contain ECS instances.
-
You can update the image in a scaling configuration either manually or automatically. For more information, see Manual vs. automatic updates.
ImportantWhen you use an image update task, the system automatically creates a custom image from the source ECS instance. This operation incurs fees for the corresponding snapshot capacity. For more information, see Snapshot billing.
Manual vs. automatic updates
-
Manual update: Best suited for infrequent changes. This method is highly flexible and gives you full control over the process.
-
Automatic update: Ideal for frequent application releases. You create an update task in the Auto Scaling console, and the system automatically creates a custom image from a source ECS instance and updates the scaling configuration. Compared to the manual method, this approach requires less manual intervention and significantly reduces wait times.
The following table compares the two methods with an example.
|
Scenario |
Manual update |
Automatic update |
|
|
|
Manually update an image
Log on to the Auto Scaling console.
In the navigation pane on the left, click Scaling Groups.
In the top navigation bar, select a region.
-
Find the target scaling group and click View Details in the Actions column.
At the top of the page, click the Scaling Configurations tab.
-
In the list of scaling configurations, find the target configuration and click Edit Image in the Actions column.
NoteYou can modify the image regardless of whether the scaling configuration is Active or Pending.
-
In the Edit Image panel, select an image type and a specific image, and then click OK.
Supported image types include Public Image, User-Defined Image, and Shared Image. For more information, see Image overview.
After the update, check the Image column in the list of scaling configurations. The new image name confirms a successful update.
Automatically update an image
Differences from rolling updates
-
Automatic image updates ensure that all new instances created in the scaling group use the new image version. For instructions, see the Procedure section of this topic.
-
A rolling update gradually upgrades the images of existing instances in the scaling group to a new image. For more information, see Rolling updates.
Prerequisites
Operation Orchestration Service (OOS) executes image update tasks and requires permissions to operate on related resources. Make sure that at least one of the following conditions is met:
-
Your account has permissions to manage ECS and Auto Scaling.
-
You have created a RAM role for OOS and granted it permissions to manage ECS and Auto Scaling. For more information, see Grant RAM permissions to OOS.
NoteAttach the
AliyunECSFullAccessandAliyunESSFullAccesspolicies.
Procedure
Log on to the Auto Scaling console.
In the navigation pane on the left, click Scaling Groups.
In the top navigation bar, select a region.
-
Find the target scaling group and click View Details in the Actions column.
At the top of the page, click the Scaling Configurations tab.
Click the Update Image Tasks tab.
-
Click Update Image.
-
In the Update Image panel, configure the parameters for the update task.
The following table describes the parameters.
Parameter
Description
Instance
Select an ECS instance as the source. A custom image is created from this instance to update the scaling configuration. The custom image includes only the system disk.
Custom Image Name
Auto Scaling automatically appends a suffix to the image name to prevent conflicts with names of images generated by scheduled tasks. For example, a suffix in the format_on_{{ ACS::ExecutionId }}_at_{{ Acs::CurrentDate }} is added. ACS::ExecutionId is the execution ID in OOS, and Acs::CurrentDate is the execution time.
Configuration Source
This parameter is set to Scaling Configuration by default.
Scaling Configuration ID
Select the scaling configuration or configurations to update.
Executed At
Specify when to run the image update task:
-
Now: Run the task immediately.
-
scheduled: Run the task at a specified time, accurate to the minute.
-
Periodic: Run the task on a recurring schedule. You must specify the recurrence period, recurrence end time, and daily start time. For example, a task configured on August 17, 2020, with the following settings:
-
Recurrence: Monthly
-
Runs on the 21st to the 25th day of each month
-
Start Time: 02:00
-
Expired At: 00:00 on August 26, 2020
Effect: The task runs once per day at 02:00 from August 21, 2020, to August 25, 2020.
-
Permission Source
Select the source of permissions for OOS to operate on related resources:
-
Use Existing Permissions of Current Account: Uses the permissions already granted to your current account.
-
Specify RAM Role and Use Permissions Granted to This Role: Select a RAM role for OOS to assume and use its permissions.
NoteFor scheduled or Periodic tasks, you must specify a RAM role.
-
-
Click OK.
The image update task runs automatically at the scheduled time. After the task is created, you can view its details on the Update image tasks tab. The list displays the Task ID, Configuration source, Source details, Execution time, and Status for each task. In the Actions column, click Details to view progress or Cancel to stop a running task.
After the task succeeds, go to the Scaling Configuration tab to verify the result. If the image name in the scaling configuration follows the
UpdateImage_from_<SourceECSInstanceID>_on_<UpdateImageTaskID>format, the update was successful. On the Scaling configurations tab, you can view the scaling configurations, including their scaling configuration ID/name, instance types, status, image, bandwidth billing method, system disk type, and data disks. You can also perform operations such as Modify, Enable, Delete, Modify image, and Modify instance type.