Help Center> CodeArts> Best Practices> Huawei E2E (HE2E) DevOps Practice> Procedure> Step 6: Deploying an Application (ECS)
Updated on 2023-12-04 GMT+08:00

Step 6: Deploying an Application (ECS)

This section uses phoenix-sample-standalone as an example to describe how to deploy the release package to a host. For CCE-based deployment details, see Step 6: Deploying an Application (CCE).

Purchasing and Configuring an ECS

Elastic Cloud Server (ECS) is used in this document. You can also use your own Linux host (running Ubuntu 16.04 OS).

  1. Buy an ECS.

    The following table lists mandatory configurations. You can also select other configurations as you need.

    Table 1 Configuring an ECS purchase

    Category

    Configuration Item

    Suggestion

    Configure Basic Settings

    Billing Mode

    Select Pay-per-use.

    CPU Architecture

    Select x86. If this configuration item does not exist, ignore it.

    Specifications

    Select General computing with 2 vCPUs and 8 GiB memory or higher.

    Image

    Choose Public image > Ubuntu > Ubuntu > 16.04 Server 64bit.

    Configure Network

    EIP

    Select Auto assign.

    Bandwidth Size

    Select Bandwidth.

    Configure Advanced Settings

    Login Mode

    Select Password.

    Password

    Enter a custom password.

  2. Configure security group rules.

    Use ports 5000 and 5001 to verify the sample project. Therefore, add an inbound rule that allows access to ports 5000 and 5001.

    The procedure is as follows:

    1. Log in to the ECS list page, locate the ECS purchased in step 1, and click the ECS name.
    2. Click the Security Group tab and add an inbound rule in which Protocol is set to TCP and Port Range is set to 5000-5001 by referring to Configuring Security Group Rules.

Adding a Target Host to the Project

Before deploying applications to ECSs, add the target hosts to the basic resources of the project.

  1. Go to the Phoenix Mall project and choose Settings > General > Basic Resources from the navigation pane.
  2. Click Create Host Cluster, enter the name hosts, set the OS to Linux, and click Save.
  3. Click Add Target Host. In the dialog box that is displayed, configure the following information, agree to the statement, and click OK.

    Table 2 Adding a host

    Configuration Item

    Suggestion

    Host Name

    Enter a custom host name. For easy identification, use the name set when buying an ECS.

    IP

    Enter the EIP generated when buying the ECS.

    Username

    Enter root.

    Password

    Enter the password set when buying the ECS.

    SSH Port

    Enter 22.

  4. A host record is displayed on the page. If Succeed is displayed in the Verification Result column, the host is added successfully.

    If the host fails to be added, check the host configuration based on the failure details.

Installing Dependency Tools on ECS

The sample program depends on Docker and Docker-Compose, which must be installed on the target ECS.

  1. Go to the Phoenix Mall project, choose CICD > Deploy, and find the phoenix-sample-predeploy application in the list.
  2. Click and choose Edit from the drop-down list.
  3. Click the Environment Management tab and configure the host environment.

    1. Click Create Environment, enter the environment name phoenix-hostgroup, set Resource Type to Hosts and OS to Linux, and click Save.
    2. After a new environment record is added to the list, click the environment name. In the window that is displayed, click the Resources tab.
    3. Click Import Host. In the dialog box that is displayed, select the created host cluster from the drop-down list, select the host from the list, and click Import.

    If you do not have permission to create environments, contact the administrator to grant you permissions on the permission management page of the application.

  4. On the Deployment Actions tab page, edit the actions of the application.

    Click Install Docker and select phoenix-hostgroup from the Environment drop-down list. If a dialog box is displayed confirming whether you want to change the environment of the subsequent actions to phoenix-hostgroup, click OK.

  5. Click Save & Deploy to start the deployment task.

    If a message is displayed indicating successful deployment, the task is successfully executed.

  6. Log in to the ECS and run the following commands to check whether the dependency tools are successfully installed:

    • Check the Docker image version.
      docker -v
    • Check the Docker-Compose version.
      docker-compose -v

    If information similar to that in Figure 1 is displayed, the installation is successful.

    Figure 1 Checking the Docker and Docker-Compose versions

Configuring and Executing an Application

During deployment, configure the ECS in the environment list of the application and set the build task phoenix-sample-ci as the deployment source.

  1. Go to the Phoenix Mall project, choose CICD > Deploy, and find the phoenix-sample-standalone application in the list.
  2. Click and choose Edit from the drop-down list.
  3. Click the Environment Management tab and configure the host environment.

    1. Click Create Environment, enter the environment name phoenix-hostgroup, set Resource Type to Hosts and OS to Linux, and click Save.
    2. After a new environment record is added to the list, click the environment name. In the window that is displayed, click the Resources tab.
    3. Click Import Host. In the dialog box that is displayed, select the created host cluster from the drop-down list, select the host from the list, and click Import.
    4. Close the window after a message is displayed, indicating that the import is successful.

  4. On the Deployment Actions tab page, edit the actions of the application.

    1. Click Select Deployment Source. Set the deployment source by referring to Table 3.
      Table 3 Configuring the deployment source

      Configuration Item

      Suggestion

      Source

      Select Build task

      Build Task

      Select phoenix-sample-ci.

    2. Retain the default settings in actions Decompress File and Run Shell Commands.

  5. Click the Parameters tab and set parameters based on the SWR login command.

    You can obtain the login command from the console. For details, see Configuring SWR.

  6. Click Save & Deploy and start deployment.

    If a message is displayed indicating that the deployment is successful, continue with the next step. If the deployment fails, rectify the fault based on the failed action information and error information in logs.

  7. Verify the deployment result.

    Open a browser, enter http://ECS IP address:5000 in the address box, and press Enter.

    You can view the Store network menu in the navigation bar.

    Enter http://ECS IP address:5001. The page displays a success message.