To deploy applications in Serverless App Engine (SAE), you can use the SAE console or the Alibaba Cloud Toolkit for IntelliJ IDEA (Alibaba Cloud Toolkit in short) plug-in. This topic describes how to use the Alibaba Cloud Toolkit plug-in to deploy an application.
Prerequisites
- Java Development Kit (JDK) 1.8 or later is downloaded and installed.
- IntelliJ IDEA 2018.3 or later is downloaded and installed. Note The servers of JetBrains plug-ins are deployed outside China. If you cannot download or install IntelliJ IDEA due to slow network responses, Contact us.
- Alibaba Cloud Toolkit is installed and configured in IntelliJ IDEA.
Background information
Alibaba Cloud Toolkit is a free integrated development environment (IDE) plug-in provided by Alibaba Cloud. You can create an Alibaba Cloud account or use an existing Alibaba Cloud account to download and install Alibaba Cloud Toolkit in IntelliJ IDEA for free.
After you develop, debug, and test your application in your data center, you can use the Alibaba Cloud Toolkit plug-in to deploy the application in SAE.
Deploy an application in SAE
Alibaba Cloud Toolkit allows you to deploy applications in SAE only by using WAR packages, JAR packages, or images.
- In the Project section on the left side of IntelliJ IDEA, right-click the name of the project that you want to deploy and choose from the shortcut menu.
- In the Deploy to SAE dialog box, configure the application deployment parameters and click Apply to save the settings. The following table describes the parameters.
Parameter Description Region The region where the application resides. Namespace The namespace of the application Application The application name. Build - Maven Build: If you select this option to build the application, the system adds a Maven job to build the deployment package.
- Upload File: If you select this option to build the application, you must upload a WAR or JAR package.
- Image: If you select this option to build the application, you must configure an image address.
- Gradle Build: Not supported.
- Optional:In the Deploy to SAE dialog box, click Advanced. In the Advanced section, configure advanced application parameters. Note If you do not configure advanced application parameters, the settings in the SAE console are used by default.
The following table describes the parameters.
Type Parameter Example Description Deployment with JAR Packages Package Version 1.0.1 The version number of the application. JDK Open JDK 8 The version of the JDK on which the deployment package of the application depends. Web Container apache-tomcat-7.0.91 The version of the Tomcat container on which the deployment package depends. Startup Command Settings Jar Start Options custom-option The option settings that are used to deploy the JAR package. The following default startup command is used: $JAVA_HOME/bin/java $JarStartOptions -jar $CATALINA_OPTS "$package_path" $JarStartArgs
Jar Start Args custom-args The parameters that are used to deploy the JAR package. The following default startup command is used: $JAVA_HOME/bin/java $JarStartOptions -jar $CATALINA_OPTS "$package_path" $JarStartArgs
Release Policy Settings Update Strategy {"type":"GrayBatchUpdate","batchUpdate":{"batch":2,"releaseType":"auto","batchWaitTime":1},"grayUpdate":{"gray":1}} The deployment policy. Examples: - Example 1: Perform canary release for one instance and automatically release the remaining instances in two batches with a one-minute interval between the deployment of each instance.
{"type":"GrayBatchUpdate","batchUpdate":{"batch":2,"releaseType":"auto","batchWaitTime":1},"grayUpdate":{"gray":1}}
- Example 2: Automatically release the instances in two batches with no interval between the deployment of each instance.
{"type":"BatchUpdate","batchUpdate":{"batch":2,"releaseType":"auto","batchWaitTime":0}}
Hosts Binding Settings Custom Host Alias [{"hostName":"samplehost","ip":"127.0.0.1"}] The custom mappings between hostnames and IP addresses. Application Health Check Liveness {"exec":{"command":["sleep","5s"]},"initialDelaySeconds":10,"timeoutSeconds":11} The details of the availability check that was performed on the container. If the container fails this health check multiple times, the system disables and restarts the container. The health check can be performed only by sending commands in a container. {"exec":{"command":["sleep","5s"]},"initialDelaySeconds":10,"timeoutSeconds":11}
Readiness {"exec":{"command":["sleep","6s"]},"initialDelaySeconds":15,"timeoutSeconds":12} The readiness check of the container. If a container fails this health check multiple times, the system disables and restarts the container. Containers that fail this health check cannot receive traffic from Server Load Balancer (SLB) instances. Deployment Settings Min Ready Instances 1 The minimum number of available instances of the application. Batch Wait Time 10 The wait time between batches. Unit: seconds. Environment Variable Settings Envs [{"name":"envtmp","value":"0"}] The environment variables. - Example 1: Perform canary release for one instance and automatically release the remaining instances in two batches with a one-minute interval between the deployment of each instance.
- Click Run. You can use one of the following methods to verify that the application has been deployed:
BUILD SUCCESS
is displayed in the logs printed in the Console section of IntelliJ IDEA.- The application change record in the SAE console displays Success.
Manage Maven jobs
In the Before launch section of the Deploy to SAE page, you can add, delete, modify, or move Maven jobs.
- In the Project section on the left side of IntelliJ IDEA, right-click the name of the project that you want to deploy and choose from the shortcut menu.
- In the Before launch section of the Deploy to SAE page, manage Maven jobs.
- Add a job
- Click the icon on the right side of the Before launch section and select Run Maven Goal from the drop-down list.
- In the Select Maven Goal dialog box, select the modules available for the current project and enter the build command in the Command line field.
- Click OK.
- Delete a job: Select the job that you want to delete and click the icon on the right side of the Before launch section.
- Modify a job: Select the job that you want to modify and click the icon on the right side of the Before launch section. In the Select Maven Goal dialog box, modify the job information and click OK.
- Move a job: Select the job that you want to move and click the or icon on the right side of the Before launch section.
- Add a job
Deploy a multi-module project
A multi-module project is a project in which each module is independently developed and with call relationships among the modules. Alibaba Cloud Toolkit can be used to deploy a submodule in a multi-module project.
To deploy a submodule for a multi-module Maven project, you must execute the job of the submodule in the end in the Before launch section of the Deploy to SAE page.
- Method 1: Run the packaging and deployment commands in your parent project.
To use this method, you must use toolkit-maven-plugin V1.0.3 or later.
When you run the
toolkit:deploy
command in your parent project, add the-Ddeploy_artifacts
parameter to specify the artifact ID of the submodule that you want to deploy. If you want to deploy multiple submodules, separate them with commas (,).The following example shows the submodules of the CarShop project:
carshop itemcenter-api itemcenter detail
To deploy the itemcenter and detail submodules, run the following command in the carshop directory:
mvn clean package toolkit:deploy -Ddeploy_artifacts=itemcenter,detail
By default, the plug-in separately deploys the corresponding applications based on the
.edas_config.yaml
files of the itemcenter and detail submodules. You can also add the-Dedas_config
parameter to specify the configuration file. - Method 2: Run the packaging and deployment commands in your submodule. All the toolkit-maven-plugin versions support this method.
Run the
install
command in your parent project to install the dependencies of the submodule to your Maven local repository. Then, go to the directory of the submodule that you want to deploy and run thetoolkit:deploy
command.
References
The following table describes the operations that you can perform on an application after you deploy the application on SAE.
Operation | References |
Lifecycle management operations, such as updating, starting, stopping, and deleting an application, and scaling in or scaling out the instances for an application | |
Performance optimization operations, such as configuring auto scaling policies for an application, binding Server Load Balancer (SLB) instances to an application, and starting or stopping applications in batches | |
Application status-based operations, such as managing logs, configuring monitoring settings, viewing application events, and viewing change records |