Image update tasks are suitable for scenarios in which applications are frequently published. You need to only create an image update task in the Auto Scaling console. Auto Scaling automatically creates a custom image for the source ECS instance and replaces the image in your scaling configuration with the custom image that you create. You do not need to manually update the image in your scaling configuration. This topic describes how Auto Scaling automatically updates images in scaling configurations.

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 Elastic Compute Service (ECS) and Auto Scaling are granted to your account.
  • A RAM role is created for OOS. The operation permissions on cloud resources such as ECS and Auto Scaling is 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.

Background information

  • You can update images only for scaling groups that contain ECS instances. You cannot update images for scaling groups that contain elastic container instances.
  • Compared with the method to manually update images in scaling configurations, the automatic update method is more efficient. The update operation is simplified, and the time required to complete the update task is reduced. You do not need to invest a lot of energy and time in image update. The following table compares the method to manually update images and the method to automatically update images.
    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.
    1. Create Image B for the ECS instance on which the application of the new version is hosted. For more information, see Create a custom image from a snapshot or Create a custom image from an instance.
    2. Replace Image A specified in the scaling configuration of your scaling group with Image B.

      For more information, see Manually update images in scaling configurations.

    1. The system uses the image update feature to automatically create Image B for the ECS instance on which the application of the new version is hosted.
    2. After Image B is created, the system replaces Image A specified in the scaling configuration of your scaling group with Image B.
  • 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.

Procedure

  1. Log on to the Auto Scaling console.
  2. In the left-side navigation pane, click Scaling Groups.
  3. In the top navigation bar, select a region.
  4. Find a scaling group and go to the details page of the scaling group. You can use one of the following methods to go to the details page:
    • Click the ID of the scaling group in the Scaling Group Name/ID column.
    • Click Details in the Actions column of the scaling group.
  5. In the upper part of the page, click the Instance Configuration Sources tab.
  6. Click the Update Image Tasks tab.
  7. Click the Update Image Tasks tab.
  8. 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. The custom image is used to replace the image in the scaling configuration. The custom image is created based on the system disk of the instance.
    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.
    Execution At Specify the point in time when 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 the 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 permissions on related resources for 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 granted to this role.
    Note If you set Executed At to Scheduled or Periodic, you can only specify a RAM role.
  9. Click OK.
    The image update task is automatically executed at the specified point in time. You can view the execution status and source instance of this task in the task list. Execute the image update task

Result

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. Image update result