tencent cloud

Service Registry and Governance

Kitex-Go Integration

PDF
フォーカスモード
フォントサイズ
最終更新日: 2026-05-07 18:12:23

Scenarios

This article demonstrates the full process of CloudWeGo/kitex applications accessing the PolarisMesh governance center hosted by the microservice engine through a demo, helping you quickly learn how to use PolarisMesh.

Prerequisite

The PolarisMesh has been created. For details, see Creating a PolarisMesh Governance Center.
Download the GitHub demo source code to your local machine and extract it.
The local build environment has the golang environment installed and can access GitHub.
Based on your business needs, resources for business deployment have been prepared. You can choose either virtual machine deployment or containerized deployment.
VM deployment The CVM instance has been created. For details, see Creating a CVM Instance.
Containerized deployment The TKE container cluster has been created. For details, see Creating a TKE Cluster.

Operation Steps

1. Log in to the TSE console.
2. On the polarismesh page under PolarisMesh, click the drop-down list in the upper left corner and select the target region.
3. Click the "ID" of the target engine to go to the basic information page.
4. View the IP address. The CloudWeGo/kitex application accesses using the gRPC port (8091):


5. Modify the registry center address in the demo.
5.1 In the downloaded demo source code directory, locate the cloudwego-kitex\\provider\\polaris.yaml and cloudwego-kitex\\consumer\\polaris.yaml files respectively.
5.2 Add the Microservices Engine PolarisMesh grid address to the project configuration file (here taking cloudwego-kitex\\provider\\polaris.yaml as an example).
global:
serverConnector:
addresses:
- '10.0.4.6:8091'
6. Compile the source code into an executable program.
6.1 In the consumer and provider directories respectively, open a command prompt and run the following command to compile the project:
Compile consumer: CGO_ENABLED=0 go build -ldflags "-s -w" -o consumer
Compile provider: CGO_ENABLED=0 go build -ldflags "-s -w" -o provider
6.2 After successful compilation, two binary packages are generated as shown in Table 1.
Software Package Directory
Software Package Name
Description
cloudwego-kitex\\provider
provider
Service Provider
cloudwego-kitex\\consumer
consumer
Service Consumer
7. Deploy the provider and consumer microservices applications. Choose one deployment method based on your actual business needs from VM deployment and containerized deployment.
7.1 VM deployment Deploy the provider and consumer microservices applications.
Upload the binary package to the Cloud Virtual Machine (CVM) instance.
Run the start command to launch:
# Go to the provider directory
cd /data/polaris/cloudwego_kitex_examples/provider
# Run the provider
./provider
7.2 Containerized deployment Deploy the provider and consumer microservices applications.
Write the dockerfile to build the image. Refer to:
FROM golang:alpine
WORKDIR /root
ADD . /root
ENTRYPOINT ./[binary name] [startup parameters]
Deploy and run the image via TKE.
8. Verify the deployment results.
8.1 Go to the Micro PolarisMesh instance page mentioned earlier.
8.2 Choose Service Management > Service List to view the number of service instances:
If the number of instances is not zero, it indicates that the microservices engine has been successfully connected.
If the number of instances is 0 or the above service name cannot be found, it indicates that the EchoServerKitex application failed to connect to the microservice engine.


8.3 Invoke the HTTP interface of the consumer. Execute the http call, replacing ${app.port} with the listening port of the consumer (default: 18080), and ${add.address} with the exposed IP address of the consumer.
curl -L -X GET 'http://${add.address}:${app.port}/echo'
Expected return value: {"message":"Hi,polaris!Hi,Kitex!"}


ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック