tencent cloud

Service Registry and Governance

User Guide for Access to the Nearest Node

PDF
Focus Mode
Font Size
Last updated: 2026-05-07 18:12:23

Scenarios

This article demonstrates the full-process operation of integrating a Golang application with Polaris (Polaris) through a demo, helping you quickly understand how to use PolarisMesh's nearby routing capability.

Prerequisite

The Polaris (Polaris) instance has been created; see Create Polaris (Polaris).
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

2. In the left sidebar, select Polaris (Polaris) to go to the Polaris instance list page.
3. Click the "ID" of the target engine to go to the basic information page.
4. View the IP address. The Golang 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 nearby/consumer/polaris.yaml and nearby/provider/polaris.yaml files.
5.2 Add the Microservices Engine PolarisMesh IP address to the project configuration file (here taking nearby/consumer/polaris.yaml as an example).
global:
serverConnector:
addresses:
- 10.0.4.6:8091
location:
# Set the geographic information provider plugin for the polaris-go process to the Tencent Cloud plugin
# If the current process is in CVM or TKE, it can automatically obtain the location information of the current process.
#
# If automatic acquisition fails, you can set the plugin to env and then inject the following environment variables in linux.
# POLARIS_INSTANCE_ZONE: Set the zone information, for example ap-guangzhou
# POLARIS_INSTANCE_CAMPUS: Set the IDC information, for example ap-guangzhou-3
provider: qcloud
consumer:
serviceRouter:
# Service Routing Chain
chain:
# Routing Policy Based on Caller and Callee Service Rules (Default Routing Policy)
- ruleBasedRouter
# Nearby Routing Policy
- nearbyBasedRouter
# Description: Configuration of the service routing plugin
plugin:
nearbyBasedRouter:
# Description: Minimum matching level for nearby routing
# Scope: region (large area), zone (area), campus (data center park)
matchLevel: campus
6. Deploy the provider and consumer microservices applications. For details, see Polaris-Golang Demo deployment.
7. Go to the PolarisMesh instance page of the microservices engine mentioned earlier.
Choose Service Management > Service List to view the number of instances for the RouteNearbyEchoServer 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 RouteNearbyEchoServer service name cannot be found, it indicates that the microservice application failed to connect to the microservice engine.


Enable nearby routing for RouteNearbyEchoServer.


Confirm where the consumer's CVM (container POD) is located in Tencent Cloud.
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: Hello, I'm RouteNearbyEchoServer Provider, MyLocInfo's : xxx, host : xxx:xxx


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback