Help Center/ ServiceStage/ Getting Started/ Using ServiceStage to Host Microservice Applications
Updated on 2024-12-16 GMT+08:00

Using ServiceStage to Host Microservice Applications

ServiceStage is an application management and O&M platform that lets you deploy, roll out, monitor, and maintain applications all in one place. It supports technology stacks such as Java, PHP, Python, Node.js, Docker, and Tomcat, and supports microservice applications such as Apache ServiceComb Java Chassis (Java chassis) and Spring Cloud, making it easier to migrate enterprise applications to the cloud.

ServiceStage provides the environment management function to manage compute resources, such as Cloud Container Engine (CCE), Elastic Cloud Server (ECS), network resources, such as Elastic Load Balance (ELB) and Elastic IP (EIP), and middleware, such as Distributed Cache Service (DCS), Relational Database Service (RDS), and Cloud Service Engine (CSE) in the same VPC. In this case, when you select an environment during application deployment, the contained resources are automatically loaded.

An application is a service system with functions and consists of one or more components.

A component is a service feature implementation of an application. It is carried by code or software packages and can be independently deployed and run.

You can perform O&M operations, such as starting, stopping, upgrading, rolling back, and scaling application components, viewing logs, viewing events, setting access modes, and setting threshold alarms.

This example describes how to quickly create a microservice application based on the source code and ServiceComb (SpringMVC) framework to experience the ServiceStage functions.

ServiceStage provides demos in different languages based on GitHub. Experience the source code deployment function of the demo in a specific language on ServiceStage. For details, see How Do I Use the ServiceStage Source Code Deployment Function?

Procedure

Figure 1 shows the process of using ServiceStage to host microservice applications.

Figure 1 ServiceStage process

Prerequisites

  1. You have registered a Huawei account and enabled Huawei Cloud services.
  2. The login account has the permission to use ServiceStage. For details, see Creating a User and Granting Permissions.
  1. You have created a VPC. For details, see Creating a VPC.
  2. You have created a CCE cluster. For details, see Buying a CCE Cluster.
    • The VPC to which the CCE cluster belongs is the VPC created in 3.
    • The cluster contains at least one ECS node and is bound to an elastic IP address. (To facilitate subsequent operations, you are advised to select a node of 4 vCPUs and 8 GB memory.) For details, see Creating a Node.
    • The CCE cluster cannot be bound to other environments.

Registering a GitHub Account and Forking the Demo Source Code

  1. Register a GitHub account.
  2. Log in to GitHub.
  3. Navigate to the demo source code repository.
  4. Fork the demo source code repository to your account. For details, see Forking a repository.

Creating Repository Authorization

  1. Log in to ServiceStage using a registered Huawei Cloud account.
  2. In the region list, select a region where ServiceStage is to be used, for example, AP-Singapore.

    Figure 2 Logging in to ServiceStage

  3. Choose Continuous Delivery > Repository Authorization.
  4. Click Create Authorization. The page for creating repository authorization is displayed.
  5. Retain the default authorization name.
  6. Set Repository Authorization.

    1. Select GitHub.
    2. Select OAuth.
    3. Click Authenticate with OAuth.
    4. After reading the service statement, select I understand that the source code building function of the ServiceStage service collects the information above and agree to authorize the collection and use of the information.
    5. Click OK.
    6. Enter your GitHub account and password to log in to GitHub for identity authentication. Wait until the authorization is complete.

  7. Click OK. You can view the created authorization in the repository authorization list.

    Figure 3 Authorizing a Repository

Creating an Organization

  1. Choose Deployment Source Management > Organization Management.
  2. Click Create Organization. On the displayed page, specify Organization Name. For example, ss-org.
  3. Click OK.

Creating an Exclusive Microservice Engine

If the engine is created using an account with the minimum permission for creating engines, for example, cse:engine:create in the Fine-grained Permissions, the default VPC security group cse-engine-default-sg needs to be preset by the primary account. For details, see Creating a Microservice Engine.

  1. Choose Cloud Service Engine > Engines.
  2. Click Buy Exclusive Microservice Engine and set the parameters by referring to the following table.

    Parameter

    Description

    Billing Mode

    Select Pay-per-use.

    Enterprise Project

    default is selected by default.

    Enterprise projects let you manage cloud resources and users by project.

    It is available after you enable the enterprise project function.

    Specifications

    Retain the default value.

    Engine Type

    Select Cluster.

    Name

    Enter a microservice engine name, for example, cse-test.

    AZ

    Select an AZ for the microservice engine.

    Network

    Select a VPC and its subnets created in Prerequisites to provision logically isolated, configurable, and manageable virtual networks for your engine.

    Security Authentication

    Select Disable security authentication.

  3. Click Buy Now.
  4. Confirm the parameters. Click Submit.

    It takes about 31 minutes to create an engine. After the microservice engine is created, its status is Available.

    Figure 4 Creating a microservice engine

Creating an Environment

  1. Choose Environment Management > Create Environment. Then set required environment parameters by referring to the following table, and retain the default values for other parameters.

    Parameter

    Description

    Environment

    Enter an environment name, for example, env-test.

    Enterprise Project

    default is selected by default.

    Enterprise projects let you manage cloud resources and users by project.

    It is available after you enable the enterprise project function.

    Environment Type

    Select Kubernetes.

    HA Environment

    Select No.

    VPC

    Select the VPC prepared in Prerequisites.

    NOTE:

    The VPC cannot be modified after the environment is created.

    Configuration Mode

    Select Resource management.

    Figure 5 Creating an environment

  2. Click Create Now.
  3. In the Resource area, choose Cloud Container Engine from Compute and click Bind now.
  4. In the dialog box that is displayed, select the CCE cluster created in Prerequisites and click OK.
  5. Choose ServiceComb Engines under Middleware and click Manage Resource.
  6. In the dialog box that is displayed, select the ServiceComb engine created in Creating an Exclusive Microservice Engine and click OK.

Creating an Application

  1. Click in the upper left corner to return to the Environment Management page.

    Figure 6 Backing to Environment Management

  2. Choose Application Management > Create Application and configure the application by referring to the following table.

    Parameter

    Description

    Name

    Enter an application name, for example, servicecomb.

    Enterprise Project

    default is selected by default.

    Enterprise projects let you manage cloud resources and users by project.

    It is available after you enable the enterprise project function.

  3. Click OK.

    Figure 7 Creating an application

Creating and Deploying a Component

  1. Select the application (for example, servicecomb) created in Creating an Application and click Create Component in the Operation column.

    Figure 8 Creating a component

  2. In the Basic Information area, set the following mandatory parameters. Retain the default values for other parameters.

    Parameter

    Description

    Component Name

    Enter a component name, for example, java-test.

    Component Version

    Enter 1.0.0.

    Application

    Select the application created in Creating an Application, for example, servicecomb.

    Environment

    Select the environment created in Creating an Environment, for example, env-test.

    Namespace

    Select default to isolate component instances.

    Figure 9 Setting the basic component information

  3. In the Component Package area, set the following mandatory parameters. Retain the default values for other parameters.

    1. Stack: Select Java.
    2. Source Code/Software Package: Select Source code repository.
    3. Select GitHub.
    4. Authorization: Select the repository authorization created when Creating Repository Authorization.
    5. Username/Organization: Select the GitHub account created when Registering a GitHub Account and Forking the Demo Source Code.
    6. Repository: Select demo source code repository ServiceComb-SpringMVC forked when Registering a GitHub Account and Forking the Demo Source Code.
    7. Branch: Select master.
    Figure 10 Setting the component source

  4. In the Build Job area, set the following mandatory parameters. Retain the default values for other parameters.

    Parameter

    Description

    Organization

    Select the organization created in Creating an Organization, for example, ss-org.

    An organization is used to manage images generated during component build.

    Environment

    Select Use current environment to use the CCE cluster in the deployment environment to which the component belongs to build an image.

    In the current environment, masters and nodes in the CCE cluster must have the same CPU architecture. Otherwise, the component build fails.

    Namespace

    Select default to isolate build data.

    Figure 11 Configuring build parameters

  5. Click Next.
  6. In the Resources area, set parameters by referring to the following table.

    Parameter

    Description

    Resources

    Deselect CPU and Memory, indicating that the resource usage is not limited.

    Instances

    Set this parameter to 1.

    Figure 12 Setting component instance resources

  7. Bind a microservice engine.

    1. Choose Cloud Service Settings > Microservice Engine.
    2. Click Bind Microservice Engine.
    3. Select the managed exclusive ServiceComb engine in the current environment.
    4. Click OK.
    Figure 13 Binding a microservice engine

  8. Click Create and Deploy and wait until the component is deployed.

    Figure 14 The component is deployed.

Confirming the Deployment Result

  1. Click in the upper left corner to return to the Component Management page.

    Figure 15 Backing to Component Management

  2. Choose Cloud Service Engine > Microservice Catalog.
  3. Select a cloud service engine managed in Creating an Environment from the Microservice Engine drop-down list.

  4. Select springmvc from All applications.

    If the servicecombspringmvc microservice exists and the number of microservice instances is 1, the component instance has been connected to the microservice engine.

    Figure 16 Confirming the deployment result

Accessing an Application

  1. Choose Application Management. The application list is displayed.
  2. Click the application created in Creating an Application (for example, servicecomb). The Overview page is displayed.
  3. On the Component List tab, click the component created in Creating and Deploying a Component (for example, java-test). The Overview page is displayed.
  4. Click Access Mode.
  5. Click Add Service in the TCP/UDP Route Configuration area and set parameters by referring to the following table.

    Parameter

    Description

    Service Name

    Retain the default setting.

    Access Mode

    Select Public network access.

    Access Type

    Select Elastic IP address.

    Service Affinity

    Retain the default value.

    Port Mapping

    1. Protocol: Select TCP.
    2. Container Port: Enter 8080.
    3. Access Port: Select Automatically generated.
    Figure 17 Setting the access mode

  6. Click OK.

    Figure 18 Generating an access address

  7. Click the access address in the Access Address column to access the application, as shown in Figure 18.

    The following information is displayed:
    {"message":"Not Found"}

  8. Enter http://Access address generated in 6/rest/helloworld?name=ServiceStage in the address box of the browser to access the application again.

    The following information is displayed:

    "ServiceStage"