All Products
Search
Document Center

CloudOps Orchestration Service:Use images to update ECS instances

Last Updated:Jun 20, 2024

Scenario

When you use Elastic Compute Service (ECS) instances, you need to frequently update related programs. For example, you need to install the latest patches or update the versions of backend services for ECS instances. You can update related programs of an ECS instance by using the ECS instance image. After you update the ECS instance image, you can use the updated image to replace the system disk of the ECS instance and restart the ECS instance. This way, the ECS instance is updated. You need to replace the system disks of online running ECS instances in batches. To sum up, you need to perform the following operations:

  1. Update an ECS instance image and start a new instance. Alternatively, run commands on an ECS instance and generate a new image from the ECS instance.

  2. Replace the system disks of ECS instances in batches by using the new image.

The preceding operations are complex, and errors may occur during the process. To prevent errors and simplify O&M, CloudOps Orchestration Service (OOS) provides automated solutions for you. CloudOps Orchestration Service

Solutions

Divide instances into groups

We recommend that you divide ECS instances into groups by adding tags to the instances for easy management. For example, you can divide ECS instances into env:test and env:product groups based on the environment in which the ECS instances are used and add the corresponding tags to the instances. This way, you can select multiple ECS instances based on tags when you perform batch operations on the instances.

Generate an image

Cloud Assistant allows you to run commands on ECS instances. OOS can orchestrate API operations of Alibaba Cloud services. You can orchestrate the required commands and run the commands based on your business requirements. To update an ECS instance image, perform the following operations: Create a temporary ECS instance based on the original image and start the ECS instance, run commands on the ECS instance, and then stop the ECS instance after the commands are successfully run. Then, generate a new image from the ECS instance and release the temporary ECS instance. The following figure shows how to generate a new ECS instance image.

You can complete the preceding operations by using an OOS template. To do so, perform the following steps.

  1. Log on to the OOS console. In the left-side navigation pane, choose Automated Task > Public Template. On the Public Template page, find the ACS-ECS-UpdateImage template and click Create Execution.

    image

  2. In the Create Task wizard, configure the required parameters.

    image

  3. Create the execution and wait until the execution is complete. During the execution process, you can view the execution steps and results.

  4. After the execution is complete, view the ID of the new image that is generated.

Replace the system disks of ECS instances in batches

If you want to replace the system disks of ECS instances in batches, you must stop the ECS instances, replace the system disks of the stopped ECS instances, restart the ECS instances, and then wait until the ECS instances run as expected. These operations must be repeated on each ECS instance. We recommend that you do not manually replace the system disks of ECS instances.

You can use OOS to simplify this process. To do so, perform the following operations: Log on to the OOS console. In the left-side navigation pane, choose Automated Task > Public Template. On the Public Template page, find the ACS-ECS-BulkyReplaceSystemDisk template.

image

Click Create Execution and configure the required parameters. You can manually select ECS instances or specify ECS instances based on tags. In this example, the TargetInstance parameter is set to Specify Instance Tags and the ECS instances that have the env:test tag are selected. You can set the Rate control type parameter to Concurrency-based Control or Batch-based Control. A value of Concurrency-based Control indicates that the number of ECS instances whose system disks are concurrently replaced is constant. A value of Batch-based Control indicates that system disks of ECS instances are replaced in batches. In this example, the Rate control type parameter is set to Concurrency-based Control and the Concurrency parameter is set to 1.

image

Click Next Step: OK and then click Create. The execution is in progress and the system disks of ECS instances are replaced one by one as expected. After the execution is complete, the system disks of the ECS instances are replaced.

Related operations

You can perform the preceding steps to use an image to update ECS instances. If your ECS instances are associated with Server Load Balancer (SLB) instances, you can dissociate the ECS instances from the SLB instances before the system disks of the ECS instances are replaced, and then associate the updated ECS instances with the SLB instances for a seamless upgrade. Alternatively, you can complete the preceding operations by using an OOS template. You can also have the update process automatically triggered upon code submission.

To do so, you can create a custom template to automate the entire update process and use Alibaba Cloud CLI or an OOS SDK to execute the template after continuous integration (CI). The template that automates the update process will be provided as a public template soon. OOS helps automate the entire update process to greatly improve the O&M efficiency for you. OOS also provides visualized operation tools. The entire update process is smoother, more transparent, and more secure.