slime-io / slime

An intelligent ServiceMesh manager based on Istio
https://slime-io.github.io/
Other
420 stars 79 forks source link

meshreg: meshreg supports exporting accessed registries and implanting registry identifiers into instance metadata #498

Closed believening closed 3 months ago

believening commented 3 months ago

slime 在早些时候支持接入多个 eureka 集群/nacos 集群实现多个注册中心集群服务聚合发现。但是聚合后实例和其注册的注册中心的关联关系被丢弃了,在某些场景下,这种关联关系是必须的,pr 允许通过配置将这种关联关系植入到实例的元数据中,以被整个数据链获取并使用。

详细变更如下:

  1. EurekaServer/NacosServer 新增可选配置项 RegsitryID 以设置当前注册中心集群的标识。该标识被设置后,同时表示需要将其植入到实例元数据中。使用环境变量 REGISTRY_ID_META_KEY 设置在实例元数据中保存注册中心标识的 key。
    # meshreg config nacos 为例
    NacosSource:
    Enabled: true
    Servers:
    - RegistryID: nacos-1
    Address:
    - "http://nacos-1.test.com"
    - RegistryID: nacos-2
    Address:
    - "http://nacos-2.test.com"
    Mode: polling
  2. SE_LABEL_SELECTOR_KEYS 特性支持聚合实例元数据到 ServiceEntry 元数据,以支持不同注册中心集群注册有同名服务的场景。设置方式形如 <key>:<mapKey>:append
  3. source debug 接口新增 registries=true 参数,用于导出当前接入的注册中心信息。接口返回示例如下:
    $ curl ip-of-slime-svc:8081/meshregistry/nacos?registries=true
    [
    {
    "registry_id": "nacos-1",
    "addresses": [
      "http://nacos-1.test.com"
    ]
    },
    {
    "registry_id": "nacos-2",
    "addresses": [
      "http://nacos-2.test.com"
    ]
    }
    ]
believening commented 3 months ago

rebase merge and pls not squash @wbpcode