A scaling configuration specifies the image used to create Elastic Compute Service (ECS) instances in a scaling group. When your application changes, update the image so that new instances launch with the latest software and configuration.
Creating an image update task causes Auto Scaling to create a custom image for the source ECS instance. This incurs snapshot fees. For more information, see Snapshot billing.
This feature applies only to scaling groups of the ECS type.
Update methods
Auto Scaling provides three ways to update images:
| Method | Best for | What it does |
|---|---|---|
| Manual update | Stable environments where you control the timing | Replace the image in a scaling configuration by selecting a new image in the console. |
| Automatic update (image update task) | Frequent deployments with a repeatable schedule | Auto Scaling creates a custom image from a source ECS instance and replaces the image in the scaling configuration on a defined schedule. |
| Rolling update | Updating instances that are already running | Replaces the image on existing instances in the scaling group. For details, see Rolling update. |
Updating the image in a scaling configuration affects only instances created after the update. Existing instances continue to use their current image. To update existing instances, use a rolling update.
Manual update vs. automatic update
Consider a scaling group that uses Image A in its scaling configuration. You need to deploy a new application version using Image B.
| Step | Manual update | Automatic update |
|---|---|---|
| 1 | Create Image B from an ECS instance. See Create a custom image from a snapshot or Create a custom image from an instance. | Create an image update task. Auto Scaling creates Image B from the source ECS instance. |
| 2 | Replace Image A with Image B in the scaling configuration. | Auto Scaling replaces Image A with Image B in the scaling configuration. |
Update an image manually
-
Log on to the Auto Scaling console.
-
In the left-side navigation pane, click Scaling Groups.
-
In the top navigation bar, select a region.
-
Find the target scaling group and click Details in the Actions column.
-
In the upper part of the details page, click the Scaling Configurations tab.
-
Find the target scaling configuration and click Edit Image in the Actions column.
NoteYou can modify the image regardless of whether the scaling configuration is in the Active or Inactive state.
-
In the Edit Image dialog box, select an image type and the image, then click OK.
Available image types: Public Image, Custom Image, and Shared Image. For more information, see Overview.
Go back to the scaling configuration list. The Image column displays the new image.
Update an image automatically
An image update task automates the process: Auto Scaling creates a custom image from a source ECS instance and replaces the image in one or more scaling configurations. The custom image contains only data from the system disk of the source ECS instance.
Prerequisites
Image update tasks run through CloudOps Orchestration Service (OOS). OOS must have permission to operate on ECS and Auto Scaling resources. Meet at least one of the following requirements:
-
The current Alibaba Cloud account has operation permissions on cloud resources such as ECS and Auto Scaling.
-
A Resource Access Management (RAM) role is created for OOS with operation permissions on cloud resources such as ECS and Auto Scaling. For more information, see Grant RAM permissions to OOS.
NoteAttach the
AliyunECSFullAccessandAliyunESSFullAccesspolicies to the RAM role.
Create an image update task
-
Log on to the Auto Scaling console.
-
In the left-side navigation pane, click Scaling Groups.
-
In the top navigation bar, select a region.
-
Find the target scaling group and click Details in the Actions column.
-
In the upper part of the details page, click the Scaling Configurations tab.
-
Click the Update Image Tasks tab.
-
Click Update Image.
-
In the Update Image dialog box, configure the following parameters.
Parameter
Description
Instance
The source ECS instance. Auto Scaling creates a custom image from this instance and uses it to replace the image in the scaling configuration. The custom image contains only data from the system disk.
Custom Image Name
The name of the custom image. Auto Scaling appends a suffix in the format
_on_{{ ACS::ExecutionId }}_at_{{ Acs::CurrentDate }}, whereACS::ExecutionIdis the OOS template execution ID andAcs::CurrentDateis the task execution time.Configuration Source
Default value: Scaling Configuration.
Scaling Configuration ID
The scaling configuration to update. You can select multiple scaling configurations.
Executed At
When to run the task. Options:
-
Now -- Run immediately after the task is created.
-
Scheduled -- Run at a specified time. Specify the execution time in minutes.
-
Periodic -- Run on a recurring schedule. Specify the Recurrence, Start Time, and Expired At values.
Permission Source
The permissions OOS uses to run the task. Options:
-
Use Existing Permissions of Current Account -- Use the permissions of your Alibaba Cloud account.
-
Specify RAM Role and Use Permissions Granted to This Role -- Select a RAM role for OOS to assume.
NoteIf you set Executed At to Scheduled or Periodic, you must specify a RAM role. The Use Existing Permissions of Current Account option is not available for scheduled or periodic tasks.
Periodic task example
To run an image update task daily from August 21 to August 25, 2020, at 02:00:00:
-
Recurrence: Monthly
-
Executes from Day 21 to Day 25 of Each Month
-
Start Time: 02:00:00
-
Expired At: 00:00:00 on August 26, 2020
-
-
Click OK.
Verify the result
After the task runs, check the result:
-
On the Update Image Tasks tab, verify the task status and source ECS instance information.
-
On the Scaling Configurations tab, check the Image column. If the image name follows the format
UpdateImage_from_<Source ECS instance ID>_on_<Image update task ID>, the update succeeded.