路由标准CRD

apiVersion: com.tencent.tsf/v1alpha1

  kind:RouteRule

  metadata:

    name: ${RuleName}

    servicename: ${Service Name} # 考虑采用被 Micro Service 关联还是Label Select

    namespace: ${Namespace}

  spec:

    rules: # 路由规则,可以多条,femas站在provider视角的inbound路由,因此路由只能生效一条

    - operator: {AND,OR,EXPRESSION} # 用来判定TAG的组合方式,AND为全部满足,OR为任意满足,EXPRESSION为表达式

      tags:

      - type: ${Tag Type} # 系统标签 或 用户自定义标签

        field: ${Tag Filed} # Tag 字段

        operator: ${operator} # {EQ, NE, GT, GE, LT, LE, CONTAINS, NOT CONTAINS, EXPRESSION}

        value: ${value} # Tag 的目标值,一般是 String

      destination: # 目的地

      - weight: ${weight} # 权重,多个destination加起来需要等于100

        label: ${field} # 这里是实例的label,比如version,location,node等等

        value: ${value} # filed的值

      faultTolerant: ${true,false} 容错,流量目的地实例故障,流量转发给其他实例

容错保护机制:机制开启时,当流量目的地服务版本出现服务实例故障时,会将流量导入该服务下其他服务版本

下面是一条实际规则的描述:

apiVersion: com.tencent.tsf/v1alpha1
  kind:RouteRule
  metadata:
    name:femas-provider-routerule
    servicename: provider
  spec:
    rules:
    - operator: "OR"
      tags:
      - type: systemTag
        field: "source.service.name"
        operator: "EQUAL"
        value: "consumer"
      - type: systemTag
        field: "source.service.name"
        operator: "EQUAL"
        value: "order"
      destination:
      - weight: 20
        field: "version" # 这里是否需要用label selector来描述
        value: "1.0.0"
      - weight: 80
        field: "version"
        value: "1.0.1"
    - operator: "AND"
      tags:
      - type: systemTag
        field: "source.service.name"
        operator: "EQUAL"
        value: "shop"
      destination:
      - weight: 100
        field: "version"
        value: "1.0.0"
      faultTolerant: "true"