The background,

As a back-end developer, I received an urgent task one afternoon, which required me to quickly build a development and test environment of micro-service architecture according to customer requirements, so as to facilitate customer coordination. But we’re a small company with limited resources, and it’s hard to deploy on a PC to provide services.

After a search, there are not many vendors in the market that meet the conditions out of the box, some still require public or private cloud deployment, and even fewer can provide SaaS services out of the box.

For example, Huawei Cloud provides DevCloud, a software development platform, and Tencent Cloud launched its own R&D management platform after acquiring CODING. However, to use the services of these big manufacturers, they have to pay for their other ecological tools, which can only be abandoned in the case of limited initial investment.

Second, the CODING

Let’s take a look at CODING first, which is quite functional, from document management to project collaboration to deployment testing, but the deployment resources need to be prepared on their own, which is officially only available for 6 hours to sample clusters.

3. Huawei Cloud

DevCloud, a software development platform provided by Huawei Cloud, also has similar capabilities, although operators of such cloud services can usually only deploy applications on their own cloud servers.

Four, StarOS

Finally, on the recommendation of my friend, I found a one-stop cloud native online development platform named StarOS, which is undergoing public trial. All services are temporarily free, and it provides container cluster without operation and maintenance and out-of-the-box RESEARCH and development facilities, which meets my needs very well.

StarOS is divided into three parts: app factory, App store, and cloud coding.

1. Application factory

An application factory is, as the name suggests, a place where applications are produced and released. The biggest feature of StarOS is the use of componentized, visual, drag-and-drop application orchestration, which makes the entire architecture very clear and clear.

2. App Stores

In the app store are apps built into the platform, allowing users to quickly publish their desired apps.

3. Cloud coding

Cloud coding is an online IDE that can edit and push code referenced by code components online.

5. Build the micro-service architecture diagram

In order to facilitate other personnel maintenance, special record the process.

First things to do:

  1. Be sure to use environment variables in your code to read the address of the service being called and upload it to GitHub.
  2. Prepare the NACOS Docker image (NACOS /nacos-server:latest).
  3. Prepare the docker image for mysql8 (mysql:8).
  4. Prepare the initialization script for mysql data to be executed after the mysql database is published (github.com/alibaba/nac…) .

1. Set up mysql

Create a new mysql8 project, publish a mysql application using the mirror component, and initialize the database using THE SQL script of NACos.

The image component is easy to use, just drag an image component into the schema diagram and fill in the mysql8 Docker image address in the image address bar.

The diagram below.

Then configure the parameters of the mysql8 component to expose the network service port number 3306.

Set environment variable MYSQL_ROOT_PASSWORD to the component parameter PASSWORD. Component parameters are configurable options provided by components. Parameter values are recorded by users when publishing components, or can be passed in by output parameters of other components through cables between components.

Then set the path of the mysql storage for data persistence.

After setting up the components, save the architecture diagram and click the Publish button to publish the mysql application.

In the application publishing interface, mysql access address and 3306 port will be randomly generated, of course, you can also define.

Fill in the PASSWORD parameter value and mysql data persistent data volume can be published.

After the release, you can use the mysql access domain name and port to connect.

You can connect to the database with Navicat and initialize the mysql database with SQL scripts from NACos.

To make the mysql database available for use in other projects, click more Settings on the component in the publish-O&M Monitoring screen to turn on the switch that allows off-project calls.

With the database ready, you can set up NACOS.

2. Build nacos

After the database is set up, we adopt the same method. We create a new Spring Cloud project and build the NACOS application by using the image component. When configuring the component, the port number and environment variable Settings exposed can refer to the official Docker deployment file (github.com/nacos-group…). .

After building NACOS, use external components to introduce the mysQL8 database built in the previous step.

An external service component is a component formed by an external service invoked through a network. It can refer to components in other projects, or it can refer to components outside the system using IP or domain names.

Once the components are set up, wire the two components together.

The registry configuration center NACOS is set up.

3. Set up the Spring Boot Admin

The next step is to build a service to monitor Spring Boot Admin using code components, which are compiled and built using source server addresses such as Git.

Drag a code component into the architecture diagram and bind it to the GitHub account. When the binding is complete, the code component can pull the account to the GitHub repository.

My code uses SpringBoot, so select SpringBoot@JDK8 in the technology stack options.

Then configure the network service port of the component and import the NACOS service address through the environment variable NACOS_HOST.

Once the components are set up, connect the admin component to the nacos component using a wire.

4. Set up service producer

Follow the preceding steps to build the service producer using code components.

Configure the network service port of the component based on the actual code, and use the environment variable NACOS_HOST to import the NACOS service address.

After the component is set up, connect the producer and nacos with wires.

5. Build service Cosumers

Follow the steps above to build the service Cosumers using code components.

Configure the network service port of the component based on the actual code, and use the environment variable NACOS_HOST to import the NACOS service address.

Once the component is set up, wire the component Cosumers to the component NACos.

6. Set up the service gateway

Follow the steps above to build the service gateway gateway using the code component.

Configure the network service port of the component based on the actual code, and use the environment variable NACOS_HOST to import the NACOS service address.

Once the components are set up, connect the component Gateway to the component NACOS using a wire.

At this point, the basic framework of a Spring Cloud microservices architecture is in place.

Once the architecture is built, you can publish the application to see how it looks.

Release 7.

On the release interface, the system automatically generates random domain names and ports for each service. Of course, you can also customize the domain name and port. Note that the customized domain name and port cannot be the same; otherwise, the release fails.

After publication, the service can be accessed through the corresponding domain name.

By following the steps above, you can quickly build a microservice development and test environment on StarOS. It’s really one-click and very convenient.

In the future, I will continue to improve the microservice architecture and expect to add link tracing, message queuing, etc.