After you develop, debug, and test your application in your on-premises environment, you can install Alibaba Cloud Toolkit in IntelliJ IDEA to deploy your application to Enterprise Distributed Application Service (EDAS). This topic describes how to install Alibaba Cloud Toolkit in IntelliJ IDEA and deploy an application to a Container Service Kubernetes cluster.

Prerequisites

  • Java Development Kit (JDK) 1.8 or later is downloaded and installed. For more information, see JDK 1.8 or later.
  • IntelliJ IDEA 2018.3 or later is downloaded and installed. For more information, see IntelliJ IDEA 2018.3 or later.
    Note The official server of the JetBrains plug-in is deployed outside China. If you cannot download IntelliJ IDEA due to a slow network response, join the DingTalk group provided at the end of this topic. You can obtain the offline installation package for IntelliJ IDEA from Alibaba Cloud Toolkit technical support.
  • An application is created and deployed to a Container Service Kubernetes cluster. For more information, see Use an image to deploy an application in a Container Service Kubernetes cluster.

Step 1: Install Alibaba Cloud Toolkit

  1. Start IntelliJ IDEA.
  2. Install the latest version of Alibaba Cloud Toolkit in IntelliJ IDEA.
    If you have installed an earlier version of the installation package, upgrade Alibaba Cloud Toolkit to the latest version.
    • macOS: In the left-side navigation pane of the Preferences page, click Plugins. On the right side of the page, enter Alibaba Cloud Toolkit in the search box and click the search icon. Then, click Install. Install-Intellij-Idea-MAC-20190722.png
    • Windows: In the left-side navigation pane, click Plugins. On the right side of the page, enter Alibaba Cloud Toolkit in the search box and click the search icon. Then, click Install. edas-cloudtoolkit-installconfig-Windows-20190722.png
  3. After Alibaba Cloud Toolkit is installed in IntelliJ IDEA, restart IntelliJ IDEA. The Alibaba Cloud Toolkit icon (act icon) appears in the toolbar.

Step 2: Configure an Alibaba Cloud Toolkit account

After Alibaba Cloud Toolkit is installed, use your AccessKey ID and AccessKey secret to configure your Alibaba Cloud Toolkit account.

  1. Start IntelliJ IDEA.
  2. In the top navigation bar of IntelliJ IDEA, choose Tools > Alibaba Cloud > Preference….
  3. In the left-side navigation pane, choose Alibaba Cloud Toolkit > Accounts.
  4. On the Accounts page, specify the Access Key ID and Access Key Secret parameters and click OK.
    • If you use the AccessKey ID and the AccessKey secret of a RAM user, make sure that the RAM user is authorized to deploy applications.
    • If your EDAS is deployed on Apsara Stack Enterprise, you must configure an endpoint to use Alibaba Cloud Toolkit. Config-Idea-Cloud-Toolkit-Account.png
      • If you already have an Alibaba Cloud account, click Get existing AK/SK on the Accounts page. The logon page of Alibaba Cloud appears. After you log on to the system by using your Alibaba Cloud account, you are directed to the Security Management page. On this page, obtain the AccessKey ID and the AccessKey secret of the account.
      • If you do not have an Alibaba Cloud account, click Sign up on the Accounts page. On the page that appears, create an Alibaba Cloud account. Then, obtain the AccessKey ID and the AccessKey secret of the account by using the preceding method.

Step 3: Deploy your application to a Container Service Kubernetes cluster

  1. In the top navigation bar of IntelliJ IDEA, choose Tools > Alibaba Cloud > Deploy to EDAS > EDAS for Kubernetes Application.
    Alternatively, in the top navigation bar of IntelliJ IDEA, choose Run > Edit Configurations. In the left-side navigation pane of the Run/Debug configurations dialog box, choose Templates > EDAS on Alibaba Cloud > EDAS for Kubernetes Application.
  2. In the Deploy to EDAS dialog box, configure the application deployment parameters.
    edas-cloudtoolkit-installK8sApp-Windows-20190722.png
    1. On the Settings tab, specify Region, Namespace, and Application for the application based on your business needs.
      Notice If the application is not in the application list, you can troubleshoot the issue. For more information about the troubleshooting procedure, see FAQ.
      • Region: the region where the application is to be deployed.
      • Namespace: the namespace where the application is to be deployed.
      • Application: the name of the application.
    2. Select the deployment method that you used to deploy the application in the EDAS console.
      • Maven Build: If this option is selected to build the application, the system adds a Maven job by default to build the deployment package.
        Note For more information about how to deploy a multi-module project, see Deploy a multi-module project.
      • Upload File: If this option is selected to build the application, upload your WAR package or JAR package and then deploy the application.
      • Build Image: If this option is selected to build the application, select a working directory for Content Directory and then select a file path for Dockerfile. Then, enter an image version in the Version field. edas-cloudtoolkit-installK8sApp-BuildImage-20190722
      • Select Image: If Build Image is selected to build the application, select an image from the Select Image drop-down list to deploy the application.
    3. Click the Advanced tab. On this tab, configure the advanced deployment parameters, including Application Environment, Startup Command, Environments, Persistence, Storage, and Application Management.
      For more information about the advanced deployment parameters, see DeployK8sApplication. edas-cloudtoolkit-installK8sApp-advanced-20190722.png
      • Application Environment: Specify a runtime environment for the application. You must specify PackageVersion each time you deploy the application. edas-cloudtoolkit-installK8sApp-advanced-Application Environment.png
      • Startup Command: Specify the startup command information. For more information about the deployment parameters, see DeployK8sApplication.
      • Environments: Specify the deployment environment variables for the application. For more information about the deployment parameters, see DeployK8sApplication.
      • Persistence: Configure persistent storage. edas-cloudtoolkit-installK8sApp-advanced-persistence.png
      • Storage: Configure local storage. For more information about the deployment parameters, see DeployK8sApplication.
      • Application Management: Specify the parameters for application lifecycle management.
        • Poststart: a container hook. The hook is immediately triggered after a container is created. The hook notifies the container that the hook is created. The hook does not pass parameters to the corresponding hook handler. If the corresponding hook handler fails to be executed, the container is stopped and the restart policy of the container is used to determine whether to restart the container. For more information, see Container lifecycle hooks.
        • PreStop: a container hook. The hook is triggered before a container is deleted. The corresponding hook handler must be completely executed before the request to delete the container is sent to the Docker daemon. The Docker daemon sends an SIGTERM signal to itself to delete the container, regardless of the execution result of the corresponding hook handler. For more information, see Container lifecycle hooks.
        • Liveness: a probe that monitors your container status. The probe checks whether your applications are healthy. If an application is unhealthy, its corresponding container is deleted and re-created. For more information, see Pod lifecycle.
        • Readiness: a probe that monitors your container status. The probe checks whether your applications have been started and are running as expected. If an application is not running as expected, the container status is updated. For more information, see Pod lifecycle.
  3. Click Apply and then click Run.
    The deployment log records are displayed on the Console tab of IntelliJ IDEA. You can use the log records to check the deployment result.

Deploy a multi-module project

Most of the Maven projects are multi-module projects. A multi-module project is a project where the modules of the project can be separately developed and some of the modules may use the features of other modules.

Assume that your project is a Maven multi-module project and you want to deploy a submodule of the project. Make sure that the last Maven job in the Before launch section on the EDAS Deployment Configurations page is the build job for the submodule. For more information about how to manage Maven build jobs, see Manage Maven build jobs.

The following example shows the submodules of the CarShop project:

carshop
├── itemcenter-api       
├── itemcenter    
├── detail      

In this example, itemcenter and detail are submodules and depend on the itemcenter-api module. In this case, to deploy the itemcenter sub-module, you need only to add the following two Maven jobs in the Before launch section on the EDAS Deployment Configurations page:

  • Add a Maven job to run the mvn clean install command in the parent project CarShop.
  • Add a Maven job to run the mvn clean package command in the itemcenter submodule.

Manage Maven build jobs

In Alibaba Cloud Toolkit installed in IntelliJ IDEA, you can deploy Maven build jobs. In the Deploy to EDAS dialog box, you can add, delete, modify, or move Maven build jobs in the Before launch section.

edas-cloudtoolkit-idea-manage-APP.png

In the Select Maven Goal dialog box, click the folder icon next to the Working directory field and select all the available modules for the current project. Then, enter the build command in the Command line field.

add-maven-in-Intellij-Idea.png

FAQ

  • Why am I unable to find my application from the application list?

    In most cases, this issue occurs if your application is deployed by using a RAM user that is not synchronized to EDAS or is not authorized to deploy the application. As a result, the application is not displayed in the Application drop-down list. To resolve the issue, you can grant the required permissions to the RAM user in the Resource Access Management (RAM) console or the EDAS console and synchronize the RAM user to EDAS.

    • Authorize the RAM user in the RAM console

      You can use this authorization method to grant the RAM user the permissions to access all the EDAS resources.

      1. In the left-side navigation pane of the RAM console, choose Identities > Users.
      2. On the Users page, find the RAM user, and click Add Permissions in the Actions column for the RAM user.
      3. In the Select Policy section of the Add Permissions panel, search for the AliyunEDASFullAccess policy and click it to add it to the Selected section. Then, click OK.
      4. In the Add Permissions panel, check the summary of the authorization information and click Complete.
      5. Use your Alibaba Cloud account to log on to the EDAS console. In the left-side navigation pane, choose System Management > RAM User. In the upper-right corner of the RAM User page, click Synchronize RAM User.
    • Authorize the RAM user in the EDAS console

      You can use this authorization method to grant the RAM user the fine-grained permissions to access EDAS resources.

      1. Use your Alibaba Cloud account to log on to the EDAS console.
      2. In the left-side navigation pane, choose System Management > Roles. In the upper-right corner of the Roles page, click Create Role.
      3. Enter a role name. In the Optional Permissions section, choose Applications > Basic Information > Deploy Application. Then, click Add to add the role for application deployment to the Selected Permissions section and click OK.
      4. In the left-side navigation pane, choose System Management > RAM User. In the upper-right corner of the RAM User page, click Synchronize RAM User.
      5. Find the RAM user to be authorized, and click Manage Roles in the Original Authorization for EDAS column for the RAM user. In the Manage Roles dialog box, search for the role to be added in the Unselected section. Then, select the role and add it to the Selected section, and click OK.
      6. Find the RAM user to be authorized, and click Applications Authorized in the Original Authorization for EDAS column for the RAM user. In the Applications Authorized dialog box, search for the application that you want to deploy in the Unselected section. Then, select the application and add it to the Selected section, and click OK.
  • How do I configure an endpoint?
    Note If your EDAS is deployed on Apsara Stack Enterprise, you must configure an endpoint in Alibaba Cloud Toolkit. To obtain an endpoint, contact EDAS technical support.
    1. In the left-side navigation pane of the Preference (Filtered) dialog box, choose Appearance & Behavior > Endpoint.
    2. On the Endpoint page, configure an endpoint and click Apply and Close.