slime-io / slime

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

meshreg: support relabeling metadata for nacos instance #345

Closed believening closed 1 year ago

believening commented 1 year ago

SourceArgs adds InstanceMetaRelabel field to configure how to relabel instance metadata. The source implementation needs to be able to map the original metadata Key in the instance to the TargetKey, using the value of the Key as the value of the TargetKey by default, and remapping the value of the Key to another value as the value of the TargetKey if necessary. When the TargetKey already exists, it is possible to overwrite or skip this relabel according to the Overwrite parameter.

Note: pr provides an implementation for nacos source only.


examle:

  1. Use the value of namingPrefix in the service instance metadata to concatenate the original service name above as the service name of the converted SE;
  2. If the metadata namingPrefix does not exist , use the value of the metadata env instead;
  3. If the value of env is prod, expand it to product.
LEGACY:
  NacosSource:
    Enabled: true
    Mode: polling
    Servers:
    - Address:
      - "127.0.0.1:8848"
    InstanceMetaRelabel:
      Items:
      - Key: env
        TargetKey: namingPrefix
        ValuesMapping:
          prod: "product"
    ServiceNaming:
      Sep: "."
      Items:
      - Kind: "meta"
        Value: "namingPrefix"
      - Kind: "$"
        Value: "service"