slime-io / slime

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

Introduce RegistrySources CRD to dynamically configure meshreg #434

Closed believening closed 1 year ago

believening commented 1 year ago

In the mr312 , we introduced the capability of configuration hot updating for the meshregistry module. We also added support for the nacos source and zk source.

The hot updating of meshregistry configuration relies on a complete meshreg bootstrap.RegistryArgs object, and it fully adopts the configuration sent during hot updating. Furthermore, when deploying new configurations through configmap, in order to preserve the configuration hot updating capability of other modules, it is required that the data format in the configmap remains consistent with the data format during deployment, which adds additional cost.

Considering that the usage scenario of meshregistry hot updating is mostly for adjusting the instance filter behavior of different sources, and the bootstrap.RegistryArgs configuration API prioritizes flexibility, it is prone to errors during modification and needs to be populated into the configmap, further increasing the probability of errors.

Therefore, we have introduced a brand new CRD RegistrySources for dynamically configuring meshregistry. RegistrySources provides a more user-friendly API to merge configurations into the original configuration or the dynamically configured configuration based on the configmap using the patch method.


CRD RegistrySources, like other slime CRDs, belongs to the microservice.slime.io group and evolves from version v1alpha1. RegistrySources uses golang to complete the original description and utilizes the Kubernetes community toolchain to generate resources including CRDs. After updates, you can execute MODULES=meshregistry make modules-k8s-gen to update the relevant resources.

In the current version, RegistrySources defines the behavior of filtering instances for the zk source, including visible Dubbo interfaces and invisible instance IPs. The CRD RegistrySources itself is not displayed here. You can obtain it from the code. An example of converting RegistrySources to bootstrap.RegistryArgs is as follows:

# the example spec of a RegistrySources cr
spec:
  zookeeper:
    availableInterfaces:
      - interface: com.alibaba.dubbo.demo.DemoService
        group: slime
        version: 1.0.0
      - interface: com.alibaba.dubbo.demo.DemoService
        group: slime
        version: 2.0.0
    globalAbnormalInstanceIPs:
      globalAbnormalInstanceIPs1:
        - 1.1.1.1
      globalAbnormalInstanceIPs2:
        - 2.2.2.2
    abnormalInstanceIPs:
      com.alibaba.dubbo.demo.DemoService:slime:3.0.0: # interface:group:version
        - 3.3.3.3
        - 3.3.3.4
# the converted bootstrap.RegistryArgs.ZookeeperSource
EndpointSelectors:
  - ExcludeIPRanges:
      IPs:
        - 1.1.1.1
        - 2.2.2.2
    matchLabels:
      interface: com.alibaba.dubbo.demo.DemoService
      group: slime
      version: 1.0.0
  - ExcludeIPRanges:
      IPs:
        - 1.1.1.1
        - 2.2.2.2
    matchLabels:
      interface: com.alibaba.dubbo.demo.DemoService
      group: slime
      version: 2.0.0
ServicedEndpointSelectors:
  com.alibaba.dubbo.demo.DemoService:slime:3.0.0:
    - ExcludeIPRanges:
        IPs:
          - 3.3.3.3
          - 3.3.3.4