You can use the toolkit-maven-plugin plug-in to update Spring Cloud, Dubbo, and High-Speed Service Framework (HSF) applications that are deployed in an Elastic Compute Service (ECS) cluster in Enterprise Distributed Application Service (EDAS).
Prerequisites
Spring Cloud, Dubbo, and HSF applications are created in EDAS.
Background information
The toolkit-maven-plugin plug-in is an open source tool that you can use to build a complete application lifecycle framework and deploy an environment for a project. For more information, see toolkit-maven-plugin overview.
You can 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 the same time.
Procedure
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>
NoteWe recommend that you set version to
1.1.5
. The latest version may not be supported.Create a configuration file named .edas_config.yaml in the root directory of the project and configure deployment parameters in the file.
The file that is 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 configure the-Dedas_config=xxx
parameter to specify the configuration file 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.
NoteIf the current project is a submodule of a Maven project, the default configuration file must be stored in the root directory of the submodule. For information about how to deploy a multi-module project, see Deploy multi-module projects.
Sample configurations of typical update scenarios:
Update all 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 want to update all the instance groups of the application. The following sample code provides an example of the configurations:env: region_id: cn-beijing app: app_id: eb20****-e6ee-4f6d-a36f-5f6a5455****
Replace the parameter values in the preceding code with actual values.
Update a specific 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 want to update the instance group whose ID is06923bb9-8c5f-4508-94d8-517b692f****
and specify 1.2 as the deployment package version for the application. The following sample code provides an example of the configurations:env: region_id: cn-beijing app: app_id: eb20dc8a-e6ee-4f6d-a36f-5f6a5455**** package_version: 1.2 group_id: 06923bb9-8c5f-4508-94d8-517b692f****
You may need to configure more parameters in complex scenarios. For more information, see Configure the parameters related to application deployment.
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 Resource Access Management (RAM) user to which you have granted the Application Management permissions. This way, you can manage permissions on the application. This helps improve application security. You can view the AccessKey IDs and AccessKey secrets of RAM users on the AccessKey Pair page of the RAM console.
Sample account file:
access_key_id:yourAccessKeyId access_key_secret:yourAccessKeySecret
NoteReplace the values of the
yourAccessKeyId
andyourAccessKeySecret
parameters with your actual AccessKey ID and AccessKey secret. The AccessKey ID and AccessKey secret in the account file are used to only generate request signatures. The AccessKey pair is not used for other purposes, such as data transmission.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 in EDAS:
mvn clean package toolkit:deploy -Daccess_key_file={account file path}
Command parameter description:
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 configure this parameter.
access_key_file: the path of the account file.
NoteFor more information about how to specify a key pair, see Account configurations and priorities.
-Djar_path: the file path of an existing deployment package. 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 or relative path. To specify the file path of an existing deployment package, run the following command:
mvn toolkit:deploy -Daccess_key_file={account file path} -Djar_path=target/demo.jar
ImportantYou can also configure the path of the account file when you configure env parameters. For more information, see Configure the parameters related to application deployment. However, the
-Djar_path
parameter takes precedence over env parameters.
Check the result
Run the command to encapsulate the project and deploy the application, and then query output logs on the Terminal interface of the IDE.
If the output logs contain BUILD SUCCESS, the application is deployed.
If the output logs contain ERROR, identify the cause of the error based on the logs. Fix the error and redeploy the application.
Log on to the EDAS console, view the change records and application details, and check whether the application is updated or deployed. For more information, see Check 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.