All Products
Search
Document Center

Publish Java applications in ECS cluster

Last Updated: Aug 06, 2019

Scenario description

To help you get started, EDAS provides a Java web application demo that only contains a welcome page, so that you can quickly publish it on multiple ECS instances.You need to create the ECS instances on Alibaba Cloud and deploy them in Alibaba Cloud VPCs.

Prerequisites

You have completed the following preparatory steps for application development:

  1. Activate EDAS.
  2. Create VPCs.
  3. Create ECS instances.
  4. Create namespaces.
  5. Create ECS clusters.
  6. Synchronize SLB instances to the EDAS console (only if you need to configure SLB).

Download application demos

Create and deploy applications

Note: Chrome browser is recommended for operations in EDAS console.

  1. Log on to the EDAS console.

  2. In the left-side navigation pane, choose Application Management > Applications.

  3. Click Create Application in the upper-right corner of the Applications page.

  4. In the Create Application dialog box, enter application information and click Next Step: Application Configurations.

    Create app in ECS cluster

    • Namespace: Select Region and Namespace from the drop-down list.If you do not select a namespace, the default namespace is automatically selected.
    • Cluster Type: Select ECS Cluster from the drop-down list and then select a specific cluster.
    • Application Name: Enter the application name.
    • Deployment Method: Select WAR or JAR.(The configuration procedure for WAR and JAR deployment methods are similar. The following describes how to deploy an application with a WAR package.))
    • Application Runtime Environment: Select the latest EDAS Container version.For example, EDAS container V3.5.1 [supports FatJar deployment].

    • Java Environment: Select JRE 8 or JRE 7.

    • Application Description: Enter up to 100 characters of basic application information.
  5. On the Application Configuration page, add an instance and configure the instance as instructed.Then, click Create.

    • Selected Instances: Click Add. On the displayed Instances page, select an instance and click > to add the instance to the right area, and then click OK.

      • For no instance selected: Click Create Empty Application to create an empty application.Then, click Scale Out, Add Instance, or Deploy Application to publish the application.

      • For an instance selected: Click Create to create an empty application containing instances.Then, click Deploy Application to publish the application.

    • Deploy Now: This option is available only after you select an instance.Enable Deploy Now and configure the parameters as instructed on the page.

      Create app in ECS clus deploy now

    • File Uploading Method: Select Upload WAR Package or WAR Package Location.

      • Upload WAR Package: Click Download Sample WAR Package. After the sample package is downloaded, click Select File and select a WAR package.
      • WAR Package Location: Right-click Download Sample WAR Package and copy the link address. Paste the link address to the WAR package address bar.

        Note: The name of an application development package can contain letters, digits, hyphens (-), and underscores (_). A JAR package can be uploaded only if the selected version supports JAR deployment. Otherwise, the application must be deployed through a WAR package.

    • Version: Set a version (for example, 1.1.0) for the application. We recommend that you do not use a timestamp as the version number.

    • Application Health Check (optional): Set a URL for application health checking.The system checks the health of the application after the container is started or is running to see whether the application is working normally. Then, it performs a service routing task based on the results of the health check.A sample URL is as follows: http://127.0.0.1:8080/healthCheck.html

    • Batch: Specify the number of batches. If you select two or more batches, you need to set the Interval.

    • Batch Mode: Select Automatic.
  6. Wait several minutes until the application is created.After creating an application, go to the Application Details page to view the application.On the Instance Information tab page of the Application Details page, view the running status of the application instance.If the running status/time is Running, the application is published successfully.

Deploy and update applications

If only an empty application is created, on the Application Details page, click Deploy Application to deploy the application. If the created application has been deployed, click Deploy Application to update the application.

  1. Log on to the EDAS console. In the left-side navigation pane, choose Application Management > Applications. On the Applications page, click the name of the application to be deployed.

  2. On the Application Details page, click the Instance Information tab. On the tab page that is displayed, check whether an instance is available for the application. If not, click Scale Out to add at least one instance for the application.

  3. Click Deploy Application, follow the instructions on the interface to set the deployment parameters, and click Publish.

    Deploy app

    • Deployment Method:
      • For a new application: Select WAR, JAR, or Historical Version to deploy the application.
      • For an upgraded application: Select the method used for the first deployment or Historical Version to deploy the application.
    • File Uploading Method: Select Upload WAR Package or WAR Package Location (in the example, a WAR package is used).
      • Upload WAR Package: Click Download Sample WAR Package. After the sample package is downloaded, click Select File and select a WAR package.
      • WAR Package Location: Right-click Download Sample WAR Package and copy the link address. Paste the link address to the WAR package address bar.
    • Enter Version Number: Set a version (for example, 1.2.0) for the application. We recommend that you do not use a timestamp as the version number.
    • Group: Select a group.
    • Batch: Specify the number of batches. If you select two or more batches, you need to set the Interval.
    • Batch Mode: Select Automatic.
    • Java Environment (optional): Select JRE 8 or JRE 7.
    • Application Description: The description can be blank. The description content should describe the purpose of publishing this application.The maximum length of the content is 128 characters.
  4. The file upload progress is shown at the top of the dialog box. After the progress reaches 100%, you are redirected to the Change Details page, where you can view the deployment process and operation log.After you complete the deployment, the execution status becomes Execution Successful.

Verify the results of application publishing

After publishing an application, you can view the instance running status or log on to the SLB instance for address configuration to verify that the application is published successfully.

View the running status of the application instance

On the Instance Information tab page of the Application Details page, view the running status of the ECS instance.If the running status/time is Running, the application is published successfully.

Configure Internet SLB and access the application

Because the application is created and published in the VPC, it has no public IP address unless configured specially.If you deploy your application on multiple ECS instances and want to allow external access, we recommend that you configure Internet SLB instances to distribute application access traffic to ECS instances based on a forwarding policy. This enhances the service capabilities and application availability.

  1. In the Application Settings area on the Basic Information page, click Add to the right of SLB (Internet).

  2. In the Bind SLB to Application dialog box that appears, set the SLB parameters and click Configure SLB.

    Binding SLB

    • SLB (Internet): Select the intranet or Internet address of the SLB instance as needed from the drop-down list.
    • Use VServer Group: A VServer group is a group of frontend ECS instances used to process requests distributed by SLB instances.Different listeners can be associated with different VServer groups to distribute different requests to different backend servers.If you select Use VServer Group, you must configure the VServer Group parameter.
    • VServer Group Name: Enter the name for the new VServer group if you select Create VServer Group.The system creates a VServer group with the specified name.
    • Listener (Internet): SLB listeners regulate how requests are forwarded to backend servers.At least one listener must be created for each SLB instance.You can select a listening port from the Listener drop-down list.If no listener has been created, click Create New Listener.- Do not delete the listener in the SLB console; otherwise, the application cannot be accessed normally.
    • SLB Frontend Protocol: The default setting is TCP, which cannot be configured manually.
    • SLB Frontend Port: Enter the frontend port of the SLB instance.
    • Application Port: The default setting is 8080, which cannot be configured manually.
  3. Copy the URL consisting of the IP address and port of the SLB instance, for example, 118.31.159.169:81. Then, paste it into the address box of the browser and press Enter. The welcome page of the application appears.