An image contains information that is required to create Elastic Compute Service (ECS) instances, such as the system and application environments, and related software configurations. Images in scaling configurations must be frequently updated to meet changing business requirements. An image in a scaling configuration is frequently updated to meet business requirements. You can manually update the image in your scaling configuration, or enable Auto Scaling to automatically update the image.
Background information
- You can manually update images only for scaling groups that contain ECS instances. You cannot update images for scaling groups that contain elastic container instances.
- Images can be manually updated or automatically updated. For more information, see Comparison of manual image update and automatic image update.
- If you use the image update feature to automatically create a custom image for the source ECS instance, you are charged when you use snapshots. For more information, see Snapshots.
Comparison of manual image update and automatic image update
If traffic to your application is stable and fluctuates only in specific cases, you can manually update images. If your application needs to be frequently published, you can create image update tasks in the Auto Scaling console. Then, Auto Scaling automatically executes the image update tasks to create images for source ECS instances and replaces the images in scaling configurations with the new images. Compared with manual image update, automatic image update is more efficient. The update operation is simplified, and the time that is required to complete the update task is reduced. You do not need to invest a large amount of effort and time to update images. The following table compares manual image update and automatic image update.
Scenario | Manual update | Automatic update |
---|---|---|
Your scaling group contains a group of ECS instances, and the scaling configuration of your scaling group uses Image A. You want to update Image A to Image B when you publish a new version of an application. |
|
|
Manually update images in scaling configurations
- Log on to the Auto Scaling console.
- In the left-side navigation pane, click Scaling Groups.
- In the top navigation bar, select the region where Auto Scaling is activated.
- Find the scaling group for which you want to replace the image and click Details in the Actions column.
- In the upper part of the page, click the Instance Configuration Sources tab.
- On the page that appears, click the Scaling Configurations tab.
- On the Scaling Configurations tab, find the scaling configuration that you want to manage and click Edit Image in the Actions column. Note You 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 an image of the selected type. Then, click OK. The following image types are supported: Public Image, Custom Image, and Shared Image.After the image is updated, you can view the Image column that corresponds to the scaling configuration. If the name of the new image is displayed, the image is updated.
Automatically update images in scaling configurations
Compare image update with rolling update
- Image update allows automatic update of images in scaling configurations. This way, instances that are created based on the scaling configurations can use the new images. For more information, see the Procedure section of this topic.
- Rolling update allows images that are used by existing instances in scaling groups to be updated to the latest version. For more information, see Rolling update.
Prerequisites
Image update tasks are executed by using Operation Orchestration Service (OOS). You must authorize OOS to perform operations on related resources. Make sure that at least one of the following requirements is met:
- The operation permissions on cloud resources, such as ECS and Auto Scaling, are granted to your Alibaba Cloud account.
- A RAM role is created for OOS. The operation permissions on cloud resources, such as ECS and Auto Scaling, are granted to the RAM role. For more information, see Configure RAM permissions for OOS. Note We recommend that you attach the AliyunECSFullAccess and AliyunESSFullAccess policies to the RAM role.
Procedure
- Log on to the Auto Scaling console.
- In the left-side navigation pane, click Scaling Groups.
- In the top navigation bar, select the region where Auto Scaling is activated.
- Find the scaling group for which you want to replace the image and click Details in the Actions column.
- In the upper part of the page, click the Instance Configuration Sources tab.
- Click the Update Image Tasks tab.
- Click the Update Image Tasks tab.
- Configure the parameters of the image update task. The following table describes the parameters.
Parameter Description Instance Select an ECS instance. Auto Scaling creates a custom image for the instance based on the system disk of the instance. The custom image is used to replace the image in the scaling configuration. Custom Image Name Auto Scaling automatically adds a suffix to the custom image name to ensure that the name is not the same as the image name that is generated by a scheduled task. Suffix format: _on_{{ ACS::ExecutionId }}_at_{{ Acs::CurrentDate }}. In the preceding format, ACS::ExecutionId specifies the ID of the image update task that you want to execute by using OOS, and Acs::CurrentDate specifies the execution time. Configuration Source By default, Scaling Configuration is selected. Scaling Configuration ID Select one or more scaling configurations for which you want to update images. Executed At Specify the point in time at which you want to execute the image update task. - Now: The task is immediately executed after the task is created.
- Scheduled: The task is executed at a specified point in time. You must specify the execution time in minutes.
- Periodic: Specify the recurrence period, expiration time, and start time of the image update task. Sample settings:
- Recurrence: Monthly
- Execute from Day 21 to Day 25 of Each Month
- Start Time: 02:00
- Expired At: 00:00 on August 26, 2020
The image update task is executed at 02:00 each day from August 21, 2020 to August 25, 2020.
Permission Source Specify the source of the permissions on related resources of OOS. Valid values: - Use Existing Permissions of Current Account: Use the permissions of the current account.
- Specify RAM Role and Use Permissions Granted to This Role: Select a RAM role for OOS to assume and use the permissions that are granted to this role.
Note If you set the Executed At parameter to Scheduled or Periodic, you can specify only a RAM role. - Click OK. The image update task is automatically executed at a specified point in time. You can view the execution status and source instance of the task in the task list.After the image update task is executed, you can view the result on the Scaling Configurations tab. If the image name in the scaling configuration is in the
UpdateImage_from_<Source ECS instance ID>_on_<Image update task ID>
format, the image in the scaling configuration is updated.