tencent cloud

Service Registry and Governance

Eureka Protocol Employs Namespace

PDF
Modo Foco
Tamanho da Fonte
Última atualização: 2026-05-07 18:12:23

Introduction

Polaris fully supports all Eureka APIs. Since Eureka does not natively support namespaces, Polaris extends a request header x-namespace to enable namespace isolation. When a client request reaches the server, the server will check this header:
If the header exists, the namespace identified by this header is used to isolate service registration and discovery.
If the header does not exist or is empty, the default namespace default is used.

Examples

The following demonstrates using the eureka protocol api: Register an instance for service EUREKA-DEMO-PROVIDER in namespace ns1 with the instance port set to 18081.
curl -X 'POST' 'http://127.0.0.1:8761/eureka/apps/EUREKA-DEMO-PROVIDER' \\
-H "Content-type: application/json" \\
-H "Accept: application/json" \\
-H "x-namespace: ns1" \\
-d '{
"instance": {
"instanceId": "10.91.80.100:eureka-demo-provider:18081",
"hostName": "10.91.80.100",
"app": "EUREKA-DEMO-PROVIDER",
"ipAddr": "10.91.80.100",
"status": "UP",
"overriddenStatus": "UNKNOWN",
"port": {
"$": 18081,
"@enabled": "true"
},
"securePort": {
"$": 443,
"@enabled": "false"
},
"countryId": 1,
"dataCenterInfo": {
"@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
"leaseInfo": {
"renewalIntervalInSecs": 30,
"durationInSecs": 90,
"registrationTimestamp": 0,
"lastRenewalTimestamp": 0,
"evictionTimestamp": 0,
"serviceUpTimestamp": 0
},
"metadata": {
"management.port": "18081"
},
"homePageUrl": "http://10.91.80.100:18081/",
"statusPageUrl": "http://10.91.80.100:18081/actuator/info",
"healthCheckUrl": "http://10.91.80.100:18081/actuator/health",
"vipAddress": "EUREKA-DEMO-PROVIDER",
"secureVipAddress": "EUREKA-DEMO-PROVIDER",
"isCoordinatingDiscoveryServer": "false",
"lastUpdatedTimestamp": "1681266990026",
"lastDirtyTimestamp": "1681266990889"
}
}' \\
-v
Register an instance for service EUREKA-DEMO-PROVIDER in namespace ns2 with the instance port set to 18082.
curl -X 'POST' 'http://127.0.0.1:8761/eureka/apps/EUREKA-DEMO-PROVIDER' \\
-H "Content-type: application/json" \\
-H "Accept: application/json" \\
-H "x-namespace: ns2" \\
-d '{
"instance": {
"instanceId": "10.91.80.100:eureka-demo-provider:18082",
"hostName": "10.91.80.100",
"app": "EUREKA-DEMO-PROVIDER",
"ipAddr": "10.91.80.100",
"status": "UP",
"overriddenStatus": "UNKNOWN",
"port": {
"$": 18082,
"@enabled": "true"
},
"securePort": {
"$": 443,
"@enabled": "false"
},
"countryId": 1,
"dataCenterInfo": {
"@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
"leaseInfo": {
"renewalIntervalInSecs": 30,
"durationInSecs": 90,
"registrationTimestamp": 0,
"lastRenewalTimestamp": 0,
"evictionTimestamp": 0,
"serviceUpTimestamp": 0
},
"metadata": {
"management.port": "18082"
},
"homePageUrl": "http://10.91.80.100:18082/",
"statusPageUrl": "http://10.91.80.100:18082/actuator/info",
"healthCheckUrl": "http://10.91.80.100:18082/actuator/health",
"vipAddress": "EUREKA-DEMO-PROVIDER",
"secureVipAddress": "EUREKA-DEMO-PROVIDER",
"isCoordinatingDiscoveryServer": "false",
"lastUpdatedTimestamp": "1681266990026",
"lastDirtyTimestamp": "1681266990889"
}
}' \\
-v
Query instances of service EUREKA-DEMO-PROVIDER in namespace ns1.
curl -X 'GET' 'http://127.0.0.1:8761/eureka/apps/EUREKA-DEMO-PROVIDER' \\
-H "Accept: application/json" \\
-H "x-namespace: ns1" \\
-v
## Return the instance on port 18081
Query instances of service EUREKA-DEMO-PROVIDER in namespace ns2.
curl -X 'GET' 'http://127.0.0.1:8761/eureka/apps/EUREKA-DEMO-PROVIDER' \\
-H "Accept: application/json" \\
-H "x-namespace: ns2" \\
-v
## Return the instance on port 18082
As demonstrated above, service registration and discovery for identical service names under different namespaces have been isolated through namespaces.

API Support List

Registering Service Instance

Request method: PUT
Route: /eureka/apps/{appId}
Example:
curl -X 'POST' 'http://127.0.0.1:8761/eureka/apps/EUREKA-DEMO-PROVIDER' \\
-H "Content-type: application/json" \\
-H "Accept: application/json" \\
-H "x-namespace: ns1" \\
-d '{
"instance": {
"instanceId": "10.91.80.100:eureka-demo-provider:18081",
"hostName": "10.91.80.100",
"app": "EUREKA-DEMO-PROVIDER",
"ipAddr": "10.91.80.100",
"status": "UP",
"overriddenStatus": "UNKNOWN",
"port": {
"$": 18081,
"@enabled": "true"
},
"securePort": {
"$": 443,
"@enabled": "false"
},
"countryId": 1,
"dataCenterInfo": {
"@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
"leaseInfo": {
"renewalIntervalInSecs": 30,
"durationInSecs": 90,
"registrationTimestamp": 0,
"lastRenewalTimestamp": 0,
"evictionTimestamp": 0,
"serviceUpTimestamp": 0
},
"metadata": {
"management.port": "18081"
},
"homePageUrl": "http://10.91.80.100:18081/",
"statusPageUrl": "http://10.91.80.100:18081/actuator/info",
"healthCheckUrl": "http://10.91.80.100:18081/actuator/health",
"vipAddress": "EUREKA-DEMO-PROVIDER",
"secureVipAddress": "EUREKA-DEMO-PROVIDER",
"isCoordinatingDiscoveryServer": "false",
"lastUpdatedTimestamp": "1681266990026",
"lastDirtyTimestamp": "1681266990889"
}
}' \\
-v

Health Check

Request method: PUT
Route: /eureka/apps/{appId}/{instanceId}
Example:
curl -X 'PUT' 'http://127.0.0.1:8761/eureka/apps/EUREKA-DEMO-PROVIDER/10.91.80.100:eureka-demo-provider:18081' \\
-H "x-namespace: ns1" \\
-v

Unregister

Request method: DELETE
Route: /eureka/apps/{appId}/{instanceId}
Example:
curl -X 'DELETE' 'http://127.0.0.1:8761/eureka/apps/EUREKA-DEMO-PROVIDER/10.91.80.100:eureka-demo-provider:18081' \\
-H "x-namespace: ns1" \\
-v

Query All Instances

Request method: GET
Route: /eureka/apps
Example:
curl -X 'GET' 'http://127.0.0.1:8761/eureka/apps' \\
-H "Accept: application/json" \\
-H "x-namespace: ns1" \\
-v

Query delta Instance

Request method: GET
Route: /eureka/apps/delta
Example:
curl -X 'GET' 'http://127.0.0.1:8761/eureka/apps/delta' \\
-H "Accept: application/json" \\
-v

Query All Instances Under a Specific Service

Request method: GET
Route: /eureka/apps/{appId}
Example:
curl -X 'GET' 'http://127.0.0.1:8761/eureka/apps/EUREKA-DEMO-PROVIDER' \\
-H "Accept: application/json" \\
-H "x-namespace: ns1" \\
-v

Query an instance of a specific service

Request method: GET
Route: /eureka/apps/{appId}/{instanceId}
Example:
curl -X 'GET' 'http://127.0.0.1:8761/eureka/apps/EUREKA-DEMO-PROVIDER/10.91.80.100:eureka-demo-provider:18081' \\
-H "Accept: application/json" \\
-H "x-namespace: ns1" \\
-v

Query a Specific Instance

Request method: GET
Route: /eureka/instance/{instanceId}
Example:
curl -X 'GET' 'http://127.0.0.1:8761/eureka/instance/10.91.80.100:eureka-demo-provider:18081' \\
-H "Accept: application/json" \\
-H "x-namespace: ns1" \\
-v

Query All Instances Under vip

Request method: GET
Route: /eureka/vips/{vip}
Example:
curl -X 'GET' 'http://127.0.0.1:8761/eureka/vips/EUREKA-DEMO-PROVIDER' \\
-H "Accept: application/json" \\
-H "x-namespace: ns1" \\
-v

Query All Instances Under secure vip

Request method: GET
Route: /eureka/svips/{svip}
Example
curl -X 'GET' 'http://127.0.0.1:8761/eureka/svips/EUREKA-DEMO-PROVIDER' \\
-H "Accept: application/json" \\
-H "x-namespace: ns1" \\
-v

Forcefully Isolate Instance

Request method: PUT
Route: /eureka/apps/{appId}/{instanceId}/status
Example
curl -X 'PUT' 'http://127.0.0.1:8761/eureka/apps/EUREKA-DEMO-PROVIDER/10.91.80.100:eureka-demo-provider:18081/status' \\
-H "x-namespace: ns1" \\
-v

Disable Forced Isolation

Request method: DELETE
Route: /eureka/apps/{appId}/{instanceId}/status
Example
curl -X 'DELETE' 'http://127.0.0.1:8761/eureka/apps/EUREKA-DEMO-PROVIDER/10.91.80.100:eureka-demo-provider:18081/status' \\
-H "x-namespace: ns1" \\
-v

Update metadata

Request method: PUT
Route: /eureka/apps/{appId}/{instanceId}/metadata?{key}={value}
Example
curl -X 'PUT' 'http://127.0.0.1:8761/eureka/apps/EUREKA-DEMO-PROVIDER/10.91.80.100:eureka-demo-provider:18081/metadata?k=v' \\
-H "x-namespace: ns1" \\
-v

Batch Copy

Request method: POST
Route: /eureka/peerreplication/batch
Example
curl -X 'POST' 'http://127.0.0.1:8761/eureka/peerreplication/batch' \\
-H "Content-type: application/json" \\
-H "Accept: application/json" \\
-H "x-namespace: ns1" \\
-d '{
"replicationList":[
{
"appName": "EUREKA-DEMO-PROVIDER",
"id": "10.91.80.100:eureka-demo-provider:18081",
"lastDirtyTimestamp": 1681266990889,
"overriddenStatus": "UNKNOWN",
"status": "UP",
"instanceInfo": {
"instanceId": "10.91.80.100:eureka-demo-provider:18081",
"hostName": "10.91.80.100",
"app": "EUREKA-DEMO-PROVIDER",
"ipAddr": "10.91.80.100",
"status": "UP",
"overriddenStatus": "UNKNOWN",
"port": {
"$": 18081,
"@enabled": "true"
},
"securePort": {
"$": 443,
"@enabled": "false"
},
"countryId": 1,
"dataCenterInfo": {
"@class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
"leaseInfo": {
"renewalIntervalInSecs": 30,
"durationInSecs": 90,
"registrationTimestamp": 0,
"lastRenewalTimestamp": 0,
"evictionTimestamp": 0,
"serviceUpTimestamp": 0
},
"metadata": {
"management.port": "18081"
},
"homePageUrl": "http://10.91.80.100:18081/",
"statusPageUrl": "http://10.91.80.100:18081/actuator/info",
"healthCheckUrl": "http://10.91.80.100:18081/actuator/health",
"vipAddress": "EUREKA-DEMO-PROVIDER",
"secureVipAddress": "EUREKA-DEMO-PROVIDER",
"isCoordinatingDiscoveryServer": "false",
"lastUpdatedTimestamp": "1681266990026",
"lastDirtyTimestamp": "1681266990889"
},
"action": "Register"
}

]
}' \\
-v



Ajuda e Suporte

Esta página foi útil?

comentários