You can use the toolkit-maven-plugin plug-in to update a Spring Cloud, Dubbo, or High-Speed Service Framework (HSF) application that is deployed in an Elastic Compute Service (ECS) cluster in Enterprise Distributed Application Service (EDAS).

Background information

The 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.

You also use the toolkit-maven-plugin plug-in to update an application that is deployed in a Kubernetes cluster in EDAS. For more information, see Use Alibaba Cloud Toolkit to release an application to all instances in a Kubernetes cluster at a time.

Procedure

  1. Add the following dependency for the toolkit-maven-plugin plug-in 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 specify deployment parameters in the file.
    • The file prefixed with . is the default configuration file of an integrated development environment (IDE). If no other configuration file is specified, the plug-in uses the .edas_config.yaml file in the root directory of the project as the configuration file.
    • If a configuration file that is not prefixed with . is created, you can specify the file by specifying 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 rather than the root directory of the Maven project. For more information, see Deploy multi-module projects.

    The following example shows how to update an instance group:

    • Update all the instance groups of an application

      For example, the application whose ID is eb20****-e6ee-4f6d-a36f-5f6a5455**** in the China (Beijing) region has multiple instance groups, and you need to update 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.

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

      For example, the application whose ID is eb20dc8a-e6ee-4f6d-a36f-5f6a545**** in the China (Beijing) region has multiple instance groups, and you need to update the 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 in the YAML format on your on-premises machine and specify 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 the 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 Pair 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 code are used only for reference. 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 to EDAS:
    mvn clean package toolkit:deploy -Daccess_key_file={Path of the account file}                        

    Parameters:

    • toolkit:deploy: specifies whether to deploy the application by using the toolkit-maven-plugin plug-in. The application is deployed after the project is encapsulated only when you specify this parameter.
    • access_key_file: the path of 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 specifying the -Djar_path parameter. This way, you can use an existing deployment package to deploy the application without the need to encapsulate the 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={Path of the 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 the command to encapsulate the project and deploy the application, you can query output logs on the terminal of the IDE.
    • If the output logs contain BUILD SUCCESS, the application is deployed. EDAS succeeds in using the toolkit-maven-plugin plug-in to deploy the application
    • If the 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 change records and application details, and check whether the application is updated or deployed. For more information, see Verify the result.

Apsara Stack support

The toolkit-maven-plugin plug-in can be used in Apsara Stack Enterprise V3.8.0 and later. Before you use the plug-in, configure an EDAS endpoint in the plug-in. For more information, see Configure the parameters related to application deployment. To obtain an endpoint, contact EDAS technical support.