tencent cloud

Service Registry and Governance

gRPC-Go Access

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

Scenarios

This article presents a full-process operation demonstration of integrating a gRPC-Go application with Polaris (North Star) through a demo, to help you quickly understand how to use PolarisMesh.

Prerequisite

Polaris (Polaris) has been created. See Create Polaris (Polaris).
Download the Github demo source code to your local machine and extract it.
The local build and packaging machine environment has Go installed and can use Go mod to fetch dependencies.
Based on your business needs, the resources for business deployment have been prepared. Choose one of the methods: virtual machine deployment, containerized deployment, or TEM 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.
TEM deployment The TEM environment has been created. For details, see Creating a TEM environment.

Operation Steps

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 gRPC-Go application accesses using the gRPC port (8091):


5. Modify the registry center IP address in the demo.
5.1 In the downloaded local demo source code directory, locate the two files respectively: \\examples\\quickstart\\provider\\polaris.yaml and \\examples\\quickstart\\consumer\\polaris.yaml.
5.2 Add the Microservices Engine PolarisMesh IP address to the project configuration file (taking \\examples\\quickstart\\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 the following table.
Software Package Directory
Software Package Name
Description
\\examples\\quickstart\\provider
provider
service provider
\\examples\\quickstart\\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, containerized deployment, and TEM deployment.
7.1 VM deployment
Upload the Jar package to the Cloud Virtual Machine (CVM) instance.
Run the start command to launch:
nohup [binary name] &
7.2 Containerized deployment
Write the dockerfile to build the image. Refer to:
FROM golang:alpine
WORKDIR /root
ADD . /root
ENTRYPOINT ./[binary name]
Deploy and run the image via TKE.
7.3 TEM deployment
Select the TEM environment. Note that the VPC on which the selected environment depends must be the same as the VPC on which the PolarisMesh instance created above depends:


In the selected environment, create a new TEM application. Refer to the following for parameter configuration:


Deploy the application. For parameter configuration, see (port mapping: the default port for consumer is 16011, and for provider is 16010):


Check the access path. After the consumer application is deployed, view the access IP address in Basic Information > Access Configuration. To enable public network access, edit and update to enable public network access:


8. Verify the deployment results.
8.1 Go to the Micro PolarisMesh instance page mentioned earlier.
Choose Service Management > Service List to view the number of instances for the EchoServerGRPC (provider) microservice:
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 EchoServerGRPC service name cannot be found, it indicates that the microservice application failed to connect to the microservice engine.


8.2 Invoke the HTTP interface of the consumer. Execute the HTTP call, replacing ${app.port} with the listening port of the consumer (default: 16011), and ${add.address} with the exposed IP address of the consumer.
curl -L -X GET 'http://${add.address}:${app.port}/echo?value=hello_world'
Expected return value: echo: hello_world


ヘルプとサポート

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

フィードバック