Quick Start

更新时间:
复制 MD 格式

This topic uses the SOFABoot 2.0 technology stack as an example to describe how to create and publish a SOFABoot application on the SOFAStack platform.

Note

The development and publishing process for a SOFABoot application is similar to that for an application based on the Spring technology stack.

Step 1: Create a standard workspace

A workspace is a group of resources that share network connectivity, consistent security policies, and minimal access latency. Workspaces allow you to group and manage resources. For example, you can create development, testing, and production workspaces based on your delivery needs. Resources in different workspaces are isolated from each other.

  1. Log on to the SOFAStack console.

  2. In the navigation pane on the left, click Global Settings to open the workspace list page.

  3. Click Create Workspace, select Standard Workspace, and then click Create.

  4. On the Create Workspace page, enter the following basic information.

    • Workspace ID: A globally unique ID for the workspace. It cannot be changed after it is created. Examples: dev, test, and prod.

    • Workspace Name: The display name of the workspace. Examples: Development Workspace, Test Workspace, and Production Workspace.

    • Region: The region where the workspace resides. Each workspace must belong to a region.

      Note

      The available regions are China East 2 (Shanghai) and China East 1 (Hangzhou) (Finance Cloud).

    • Network Type: Only virtual private cloud (VPC) is supported.

    • Zone: The zones for the workspace. You can select up to two zones. You can import resources into the workspace only from the configured zones. Features such as deployment and disaster recovery use these zones for grouped publishing and switchovers. We recommend that you configure two zones to support architectures such as dual-data-center high availability (HA).

  5. Click Next. On the Create VPC page, enter the following configuration information:

    • VPC Name: The name must be 2 to 128 characters in length. It must start with a letter or a Chinese character. It can contain digits, underscores (_), and hyphens (-). It cannot start with http:// or https://. We recommend that you use the same name as the workspace.

    • VPC CIDR Block: The CIDR block for the VPC. This setting cannot be changed after the VPC is created. The private IP addresses of all resources in the VPC, such as ECS, RDS, and SLB instances, are allocated from this CIDR block. The following CIDR blocks are available:

      • 10.0.0.0/9

      • 172.16.0.0/12

      • 192.168.0.0/16

    • vSwitch: Click Add vSwitch. In the Create vSwitch pop-up window, enter the following information and click Submit.

      • Name: The name of the vSwitch. The name must be 2 to 128 characters in length. It must start with a letter or a Chinese character and can contain digits, underscores (_), and hyphens (-). The system automatically generates a default name in the format of Workspace ID-vsw.

      • Zone: The zone for the vSwitch. vSwitches in different zones within the same VPC can communicate with each other through the service interconnection feature. You must create one vSwitch for each zone.

      • Custom CIDR Block: This feature is disabled by default. If you enable it, you must specify a CIDR block. The CIDR block of the vSwitch can be the same as or a subnet of the CIDR block of its VPC.

      • Subnet Mask: If Custom CIDR Block is disabled, you must select a subnet mask and a CIDR block. The default subnet mask is 24 bits, such as 172.31.0.0/24, which provides up to 65,536 private IP addresses. The mask can range from 16 to 29 bits, which provides 4 to 65,532 addresses.

      • Description: Enter a description for the vSwitch. It can be 2 to 256 Chinese or English characters in length. It cannot start with http:// or https://.

  6. Click Next. On the Create Security Group page, click Add Security Group. In the Add Security Group pop-up window, enter the following information and click Submit.

    • Security Group Name: The name must be 2 to 128 characters in length. It must start with a letter or a Chinese character. It cannot start with http:// or https://. It can contain digits, colons (:), underscores (_), and hyphens (-). The system automatically generates a default name in the format of Workspace ID-sg.

    • Description: The description can be 2 to 256 Chinese or English characters in length. It cannot start with http:// or https://.

    • Rule: Keep the default settings to allow all inbound and outbound traffic.

Step 2: Create an application

In this example, we create a SOFABoot application. Follow these steps:

  1. Log on to the application management console. In the navigation pane on the left, click Application List to open the application list page.

  2. Click Create Application.

  3. On the Create Application page, enter the following information.

    • Application Name: The name can contain letters, digits, hyphens, and underscores. It must start with a letter and end with a letter or a digit. In this example, enter sofabootdemo.

      Note

      The application name must be unique within the same tenant.

    • Technology Stack: Select SOFA Boot.

    • Application Group: Select the group to which the application belongs. If you have not created a custom group, you can select the default system group.

    • Application Tags: Classification tags for the application. These tags help you quickly retrieve applications. You can add system tags and custom tags.

    • Application Description: Enter a description for the application.

  4. Click Submit. In the success message that appears, click View Application Details to open the details page for the application that you created.

Step 3: Create an application service

  1. Log on to the Classic Application Service console. In the navigation pane on the left, choose Application Publishing > Application Service, and then click Create Service Instance.

  2. On the page that appears, enter the following information.

    • Application: Select the application that you created in the previous step.

    • Service Instance Name: The name can contain letters, digits, hyphens, and underscores. It must start with a letter and end with a letter or a digit.

    • Deployment Package: Select the deployment package for the application. You can upload a deployment package for the application on the Application Publishing > Deployment Package Management page.

    • Description: Enter a description for the service instance.

    • Technology Stack: This is automatically displayed based on the application.

    • Technology Stack Version: Select the required version.

    • Deployment Unit: Select the deployment units to which you want to publish the application.

  3. Click OK.

Step 4: Local development

For more information about how to develop locally using the SOFABoot framework, see SOFABoot Quick Start. For now, you can skip the development process. You can directly download the sample JAR package and extract it to your local machine. The applications in the sample project have already been compiled and packaged locally. The generated package is in the target directory.

Step 5: Purchase and attach resources to the application service

In this step, you will purchase an ECS instance and a public-facing SLB instance for the sofabootdemo application service that you created. Then, you will attach the ECS instance to the SLB instance.

Purchase an ECS instance

  1. Log on to the Classic Application Service console.

  2. In the navigation pane on the left, expand Application Publishing > Application Service.

  3. Find the sofabootdemo application service that you created. Click the instance name or Details to open the Application Service Instance Information page.

  4. Click the Cloud Server ECS tab, click Add, enter the required information, and then click Create to create the ECS instance.

    Important
    • For technology stack 2.0, such as SOFABoot, the supported operating system is Linux. The supported images are the CentOS 7.x and CentOS 6.x images provided by the SOFAStack platform.

    • For technology stack 1.0, such as sofa-lite2, Spring, sofa-lite-core, and sofa-lite-web, the supported operating system is Linux. The supported image is the CentOS 6.x image provided by the SOFAStack platform.

Purchase a public-facing SLB instance

  1. On the Application Service Instance Information page, select the Server Load Balancer SLB tab and click Add.

  2. On the page that appears, enter the required information, and then click OK > Create to create the SLB instance.

    • Instance Type: Select Public.

    • Listener Information: Add the following listener:

      • Frontend Protocol: HTTP

      • Port: 80

      • Backend Protocol Port: 8341

      • Keep the default values for the other properties.

Attach the ECS instance to the SLB instance

After the ECS and SLB instances are created, follow these steps to attach them:

  1. On the Server Load Balancer SLB tab, click the name of the SLB instance that you created to open its details page.

  2. In the Backend Server Group section, select the To Be Attached tab, select Same App, select the ECS instance that you created, and then click Attach.

  3. In the Attach ECS window, set Weight to 100 and click OK.

    After the attachment is complete, you can view the attached ECS instance on the Attached tab.

Step 6: Publish the application

  1. In the navigation pane on the left, choose Application Service > Deployment Package Management.

  2. Find sofabootdemo, click Manage to open the package management interface, and then click Upload Deployment Package.

  3. In the pop-up window, use the default version number, select the sample .jar package that you downloaded locally, and then click OK.

    After the upload is complete, you can see the uploaded version.

  4. In the upper-right corner of the page, click Publish Deployment. In the Publish Deployment window, select the sofabootdemo service instance and the version that you just uploaded. Click Publish Now. You are redirected to the deployment order page. Click Publish All.

    If the status on the deployment order details page is Execution Succeeded, the application is published successfully.

Step 7: Verify the result

Follow these steps to verify that the application was published successfully.

  1. In the navigation pane on the left, choose Application Service > Service Instance List. In the list, click sofabootdemo to open the instance details page.

  2. On the Server Load Balancer SLB tab, copy the service endpoint.

  3. In the address bar of your browser, go to http://{load balancer endpoint}/webapi/users/tester, for example, http://120.xx.xx.140/webapi/users/tester.

    If the page displays the following content, the application was published successfully:

    {"data":{"realName":"Real tester","userId":0,"userName":"tester"},"success":true}

Summary

You have now learned how to create and deploy a SOFABoot application using technology stack 2.0. The procedure for other technology stacks is similar. This topic does not explain the underlying principles in detail. For more information, see Application Deployment.

FAQ

Q: Why did the deployment fail even though I followed the steps in the document?

A: Check the Weight that you set in the Attach the ECS instance to the SLB instance step. Make sure that the weight is not 0.