Help Center > > Best Practices> ServiceComb on ServiceStage> ServiceComb Microservice Development

ServiceComb Microservice Development

Updated at: Feb 14, 2020 GMT+08:00

Based on ServiceStage, you can quickly create a scaffolding project for a new ServiceComb microservice. Two methods are provided based on the location where the source code is stored.

Application Source Code Managed on the Cloud

Source code is managed on the cloud, for example, DevCloud, GitHub, Gitee, Bitbucket, or GitLab. The procedure is as follows:

  1. Enter the Create a Cloud-based Project page by choosing options in the following figure.

  2. Select Create based on template.

  3. Select language Java 8.

  4. Select framework CSE-Java (SpringMVC).

  5. Select deployment system Cloud Container Engine (CCE).

  6. Enter required information.

    Parameter description is as follows:

    • Project name: Name of a new microservice, for example, hello.
    • Code Source: Location where the code of the new microservice is stored. The account information of the source code management service must be prepared in advance. This section uses GitHub as an example. When you use GitHub for the first time, you need to bind an account as prompted. After binding, select the username/organization (ServiceStage automatically obtains the list from the source code management service) and enter the repository name of the new microservice, for example, hello.
    • Repository Organization: Location where the new microservice software package is stored. If you use the organization for the first time, you can click Create Repository Organization to create an organization.
    • Cluster: Name of the container cluster to which the new microservice is to be deployed.
    • Cluster Namespace: Namespace of the container cluster to which the new microservice is to be deployed. Namespace can be used to isolate applications in a cluster. Each cluster has a default namespace named default.
    • The number of instances: Number of instances to be deployed for the new microservice.

  7. (Optional) Enter the information in Advanced Settings.

    Parameter description is as follows:

    • Resource Quota: resources required for running the new microservice. The default resource quota is 0.5 vCPU | 1 GB.
    • Set access method: If you need to access the new microservice from the public network, set the access mode as shown in the following figure.

    In the figure, Container Port indicates the service port (8080 by default) of the microservice, and Access Port indicates the port for external network access. Ensure that the port number can be a number between 1–65535.

  8. Start deployment.

    1. The following figure shows the process.

    2. The following figure shows a successful creation.

    3. View Source Code Address: You can switch to the scaffolding project code directory of the new microservice. The code directory structure is as follows (GitHub is used as an example of the code management service):

    4. Go to Pipeline: ServiceStage automatically creates a pipeline for a new microservice, including basic tasks such as code update, compilation, building, and deployment, as shown in the following figure.

      • You can click Details in Build to view details.
      • You can click Details in Deploy to view details of application management.

After all the above operations, you can download the new microservice code from the selected source code management service (such as GitHub) to local, import the code to the IDE (such as Eclipse) for service development, and roll out and verify the code through the pipeline.

User Source Code Managed Offline

This source code management is applicable to enterprises' proprietary DBs, which cannot be accessed from external.

  1. Create local project.: CSE Java SDK is the ServiceComb version on HUAWEI CLOUD.

  2. Fill in the information about the new microservice.

  3. Click Create and Download, the new microservice scaffolding project will be automatically completed, including the sample code, compilation script (for example, pom), and build script (for example, dockerfile) of the new microservice. The following figure shows the reference directory structure.

After all the above operations, you can decompress the new microservice code package to local and import the package to the IDE (for example, Eclipse) for service development.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?

Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel