You can use toolkit-maven-plugin to upgrade a Spring Cloud, Dubbo, or HSF application that is deployed on ECS clusters of EDAS.

Background information

Toolkit-maven-plugin plug-in is an open source tool that you can use to build a complete lifecycle framework and deploy an environment for a project. For more information, see toolkit-maven-plugin overview.

Toolkit-maven-plugin allows you to upgrade an application that is hosted on Kubernetes clusters. For more information, see Use Alibaba Cloud Toolkit to release an application to all instances at once (applicable to Kubernetes clusters).

Procedure

  1. Add the following dependency for toolkit-maven-plugin to the pom.xml file in the on-premises directory of the project.
    <build>
        <plugins>
            <plugin>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>toolkit-maven-plugin</artifactId>
                <version>1.1.5</version>
            </plugin>
        </plugins>
    </build>                      
  2. Create a configuration file named .edas_config.yaml in the root directory of the project and set the deployment parameters in the file.
    • The file prefixed with . is the default configuration file of an integrated development environment (IDE). If no other configuration files are specified, the plug-in uses the .edas_config.yaml file in the root directory of the project as the configuration file by default.
    • If a configuration file that is not prefixed with .is created, you can specify the file by setting the -Dedas_config=xxx parameter when you encapsulate the project.
    • If a default configuration file exists and you specify another configuration file by using the preceding parameter, the plug-in uses the specified configuration file.
    Note If the current project is a submodule of a Maven project, the default configuration file must be stored in the root directory of the submodule. The file cannot be stored in the Maven project. For more information, see Deploy multi-module projects.

    The following example shows how to upgrade an instance group:

    • Upgrade all the instance groups of an application

      For example, an application whose ID is eb20****-e6ee-4f6d-a36f-5f6a5455**** in the China (Beijing) region contains multiple instance groups. You need to upgrade all the instance groups. The following code provides an example of the configuration:

      env:
           region_id: cn-beijing
      app:
           app_id: eb20****-e6ee-4f6d-a36f-5f6a5455****                        

      Replace the parameter values in the preceding code with the actual values.

    • Upgrade a specified instance group of an application and specify the deployment package version for the application

      For example, an application whose ID is eb20dc8a-e6ee-4f6d-a36f-5f6a545**** in the China (Beijing) region contains multiple instance groups. You need to upgrade an instance group whose ID is 06923bb9-8c5f-4508-94d8-517b692f**** and specify 1.2 as the deployment package version of the application. The following code provides an example of the configuration:

      env:
        region_id: cn-beijing
      app:
        app_id: eb20dc8a-e6ee-4f6d-a36f-5f6a5455****
        package_version: 1.2
        group_id: 06923bb9-8c5f-4508-94d8-517b692f****            

    For information about how to set the parameters in the configuration file for complex scenarios, see Configure the parameters related to application deployment.

  3. Create an account file on-premises in the YAML format and configure the AccessKey ID and AccessKey secret in the file.

    We recommend that you use the AccessKey ID and AccessKey secret of a RAM user to which you have granted required permissions to manage the application. This allows you to control permissions on the application and improve application security. You can view the AccessKey IDs and AccessKey secrets of RAM users on the AccessKey Management page of the Resource Access Management (RAM) console.

    The following code provides an example of the configuration:

    access_key_id: abc
    access_key_secret: 1234567890                        
    Note The parameter values in the preceding example are used for reference only. Replace the AccessKey ID and AccessKey secret with the actual values. The AccessKey ID and AccessKey secret in the account file are used only to generate request signatures. The AccessKey pair is not used for other purposes, such as data transfers.
  4. In the on-premises directory of the project or the submodule directory of the Maven project, run the following command to encapsulate the project and deploy the application on EDAS:
    mvn clean package toolkit:deploy -Daccess_key_file={The path of the account file}                        

    Parameters:

    • toolkit:deploy: specifies whether to deploy the application by using toolkit-maven-plugin. The application is deployed only when this parameter is added.
    • access_key_file: specifies the account file.
      Note For more information about how to specify an AccessKey pair, see Account configurations and priorities.
    • You can also specify the file path of an existing deployment package by setting the -Djar_path parameter. This way, you can use an existing deployment package to deploy the application without the need to encapsulate the application project. The path of the deployment package can be an absolute path or a relative path. To specify the file path of an existing deployment package, run the following command:
      Mvn toolkit:deploy -Daccess_key_file={The path of the Alibaba Cloud account file} -Djar_path=target/demo.jar                        
      Notice You can also configure the path of the account file when you set env parameters. For more information, see Configure the parameters related to application deployment. However, the -Djar_path parameter takes precedence.

Verify the result

  1. After you run commands to encapsulate the project and deploy the application, you can query output logs in an integrated development environment (IDE) terminal.
    • If output logs contain BUILD SUCCESS, the application is deployed. Success message
    • If output logs contain ERROR, identify the error cause based on the logs. Fix the error and deploy the application again.
  2. Log on to the EDAS console, view the change logs and application details, and check whether the application is upgraded or deployed. For more information, see Verify the result.

Apsara Stack technical support

Toolkit-maven-plugin can be used in Apsara Stack V3.8.0 and later. Before you use the plug-in, perform the following steps to configure an endpoint in the EDAS console. For more information, see Configure the parameters related to application deployment. Contact EDAS technical support for endpoints.