Updated on 2024-07-01 GMT+08:00

Quick Experience

Cloud Application Engine (CAE) simplifies hosting for serverless applications. With CAE, applications can be deployed within minutes using source code, software packages, or container images. CAE supports mainstream languages such as Java, Go, and Tomcat and multiple runtime systems. It provides seamless hosting of multiple types of applications, including web applications, microservices, and APIs. Also, it supports auto scaling based on resources or custom service metrics to cope with unexpected user access traffic. Related resources are billed on the pay-per-use basis. In addition, CAE enables zero infrastructure O&M, so that users can focus more on application service development.

In this example, CAE is bound to the GitHub source code repository, and a frontend and a backend component are deployed to build and archive source code and create applications.

The following figure shows the demo logical networking and calling relationship.

  • Component CAE-frontend: Frontend GUI developed using the Vue framework. It functions as the application entry and can send requests to the backend.
  • Component CAE-backend: Backend service developed using Spring Boot. It processes requests sent by the demo-frontend component.

Prerequisites

Creating an Environment

  1. Log in to the CAE console. If you use CAE for the first time, a message is displayed indicating that no environment has been created.
  2. Click Create Now. On the displayed page, set parameters by referring to Table 1.

    Table 1 Creating an environment

    Parameter

    Description

    Environment

    Enter an environment name.

    Enterprise Project

    Select an enterprise project.

    An enterprise project facilitates project-level management and grouping of cloud resources and users. The default project is default.

    It is available after the enterprise project function is enabled.

    Virtual Private Cloud

    Select the VPC to which the environment resource belongs from the drop-down list.

    To create a VPC, click Create VPC. For details, see Creating a VPC.

    NOTE:

    The VPC cannot be modified after the environment is created.

    Subnet

    Select a subnet from the drop-down list.

    If no subnet is available, click Create Subnet to access the network console and create a subnet. For details, see Creating a Subnet for the VPC.

    NOTE:

    Keep at least two available network IP addresses for CAE configuration and optimization.

    Security Group

    Select Automatically generated.

    NOTE:

    This group must allow access from the selected subnet to both the subnet gateway address and the access addresses and ports of middleware such as RDS and CSE instances.

    Organization

    If you use CAE for the first time, select Create Organization from the drop-down list and enter an organization name.

  3. Click OK. The creation progress is displayed in the Creating environment window. Then the environment is successfully created.

Creating an Application

  1. Choose Components.
  2. Click on the right of Application on the top to create an application.
  3. Enter an application name, for example, cae_test.
  4. Click OK.

Creating a Component

Create a frontend component.

  1. In the created application, click Create Component.

    You can also click Try Now under the Getting Started template on the overview page. Select the corresponding environment and application, and click Deploy to create components demo-backend and demo-frontend.

  2. Configure the component.

    • Component: Enter cae-frontend.
    • Version: The default value is 1.0.0.
    • Specifications: Retain the default value. Change it if necessary.
    • Instances: Retain the default value. Change it if necessary.
    • Code Source: Select GitHub, and set Authorization, Username/Organization, Repository, and Branch.
      1. If you use CAE for the first time, create an authorization first. Click Create Authorization and set Authorization and Mode.
        • Authorization: Retain the default value. Change it if necessary.
        • Mode: Select Token.
        • Token: Obtain a token from the GitHub website. You can click to view details.
      2. Click OK. After the authorization is created, enter Username/Organization, Repository, and Branch.
        • Username/Organization: Select the username/organization created for GitHub.
        • Repository: Select cae-frontend.
        • Branch: Select master.
    • Language/Runtime System: Select Nodejs8.
    • Custom Build: Select Default.

  3. Click Create and Deploy Component. In the displayed dialog box, click Deploy Now. Wait until the component is deployed.

    • Configure Component: Click Configure Component to go to the component configuration page. After configuring the component by referring to Configuring a Component, click Set and Deploy Component.
    • Create and Deploy Component: Directly create and deploy a component. Select this mode if components do not need to be configured individually.
    • Cancel: Cancel the creation. The component information will not be saved.

Create a backend component.

  1. In the created application, click Create Component.
  2. Configure the component.

    • Component: Enter cae-backend.
    • Version: The default value is 1.0.0.
    • Specifications: Retain the default value. Change it if necessary.
    • Instances: Retain the default value. Change it if necessary.
    • Code Source: Select GitHub, and set Authorization, Username/Organization, Repository, and Branch.
      1. If you use CAE for the first time, create an authorization first. Click Create Authorization and set Authorization and Mode.
        • Authorization: Retain the default value. Change it if necessary.
        • Mode: Select Token.
        • Token: Obtain a token from the GitHub website. You can click to view details.
      2. Click OK. After the authorization is created, enter Username/Organization, Repository, and Branch.
        • Username/Organization: Select the username/organization created for GitHub.
        • Repository: Select cae-backend.
        • Branch: Select master.
    • Language/Runtime System: Select java8.
    • Custom Build: Select Default.

  3. Click Create and Deploy Component. In the displayed dialog box, click Deploy Now. Wait until the component is deployed.

Configuring a Component

Configure a frontend component.

  1. Choose Component Configurations.
  2. Select cae-frontend from the drop-down list in the upper part of the page.
  3. Click Edit in the Access Mode module.
  4. In the Access Component from Another Environment area, click Load Balancing > Add Load Balancer.
  5. Configure the parameters based on Table 2.

    Table 2 Configuring external network access for load balancing

    Parameter

    Description

    Load Balancer

    Select Built-in load balancer.

    Access Control

    Select Allow all IP addresses.

    If you have configured an access control whitelist or blocklist, only IP addresses in the whitelist or not in the blocklist can access the component.

    Health Check

    Use the default value Start.

    Port Settings

    • Protocol: Select TCP.
    • Listening Port: Enter 8080.
    • Access Port: Select a valid port ranging from 0 to 65,535, for example, 20,004.

      The port number must be unique.

  6. Click OK.
  7. Click Activate Settings in the upper part of the page. In the dialog box displayed on the right, confirm the configurations and click OK for the configurations to take effect.

Configure a backend component.

  1. Select cae-backend from the drop-down list in the upper part of the page.
  2. Click Edit in the Access Mode module.
  3. Select Load Balancing, click Add Load Balancer, and set parameters by referring to Table 3.

    Table 3 Configuring external network access for load balancing

    Parameter

    Description

    Load Balancer

    Select Built-in load balancer.

    Access Control

    Select Allow all IP addresses.

    If you have configured an access control whitelist or blocklist, only IP addresses in the whitelist or not in the blocklist can access the component.

    Health Check

    Use the default value Start.

    Port Settings

    • Protocol: Select TCP.
    • Listening Port: Enter 9090.
    • Access Port: Select a valid port ranging from 0 to 65,535, for example, 20,001.

      The port number must be unique.

  4. Click OK.
  5. Click Activate Settings in the upper part of the page. In the dialog box displayed on the right, confirm the configurations and click OK for the configurations to take effect.

Configure environment variables for a frontend component.

  1. Select cae-frontend from the drop-down list in the upper part of the page.
  2. Click Edit in the Environment Variables module.
  3. Click Add Environment Variable and configure the environment variable by referring to Table 4.

    Table 4 Environment variable parameters

    Parameter

    Description

    Name

    Enter VUE_APP_BASE_URL.

    Variable/Variable Reference

    Enter the backend access address, which can be obtained from Components, as shown in Figure 1.

    Figure 1 Obtaining the backend access address

    Figure 2 Configuring frontend environment variables

  4. Click Save and then click OK to complete the configuration.
  5. Click Activate Settings in the upper part of the page. In the dialog box displayed on the right, confirm the configurations and click OK for the configurations to take effect.

Accessing an Application

  1. Choose Components.
  2. Click the public network address in the Access Address column of the cae-frontend component to view the application page.

    Figure 3 Application page

    If you select the private network access mode, log in to the cluster node and run the curl command. For details, see Private Network Access.

Application O&M

  1. On the Overview page, you can view the component health status and resource usage.
  2. Select the environment, application, and component to be viewed.

    • Click Component Events to display the entire running process of the component.
    • Click Component Monitoring. The number of running instances of the current component and the CPU and memory usage of each instance are displayed.
    • Click Component Logs. The logs of each instance are displayed.