VirtualService

Rules for inbound traffic

VirtualService

VirtualService is a rule used to process inbound traffic, that is to say, it is used to describe which inbound traffic applies to this routing rule.

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  • property description
FieldTypeDescriptionRequired
namestringshould be named in the form of application name/router type. The name attribute is determined once the Router type is definedYES
hostsstring[]generally refers to the application nameNO
dubboDubboRoute[]dubbo routing rules, executed sequentially, return immediately when conditions are metNO
  • Router types are as follows:
nameDescription
StandardRouterA Router that fully uses the standard VirtualService description
to be addedto be added

DubboRoute

DubboRoute is an attribute in VirtualService, which is used to describe the boundary of the routing strategy.

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo: #DubboRoute
  - name:
    service:
    fault:
    mirror:
    retries:
    timeout:
    route details:
  • property description
FieldTypeDescriptionRequired
namestringThe name of the rule, easy to identify the purpose of the ruleNO
servicesStringMatch[]A list of service names for which the rule takes effect. You can use a specific service name or a regular * to match; if it is not configured by default, it means that all services are valid
faultdubboFaultInject[]fault injection (not implemented)NO
mirrorDestinationmirror traffic (not implemented)NO
retriesDubboRetry[]Retry related (unimplemented)NO
timeoutDubboTimeout[]timeout related (unimplemented)NO
routedetailDubboRouteDetail[]Specific traffic rules, executed sequentially, return immediately when conditions are metYES

DubboRouteDetail

DubboRouteDetail is used to describe detailed routing rules

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - routedetail: #DubboRouteDetail
    - name:
      match:
      route:
      mirror:
      retries:
      timeout:
  • property description
FieldTypeDescriptionRequired
namestringThe name of the rule details, easy to identify the purpose of the ruleNO
matchDubboMatchRequest[]matching conditionYES
routeDubboRouteDestination[]the actual destination address of the qualified trafficYES
mirrorDestinationmirror traffic (not implemented)NO
retriesDubboRetry[]Retry related (unimplemented)NO
timeoutDubboTimeout[]timeout related (unimplemented)NO

DubboMatchRequest

DubboMatchRequest is used to describe the matching rules of the request

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - route detail:
    - match: #DubboMatchRequest
      - name:
        method:
        sourceLabels:
        attachments:
        headers:
        threshold:
  • property description
FieldTypeDescriptionRequired
namestringmatching rule nameYES
methodDubboMethodMatchmethod related matchingYES
sourceLabelsmap<string, string>Related labels typed by the caller, including application name, machine group, machine environment variable information, etc.; for HSF-JAVA, you can get the corresponding key from the reported URL/ valueYES
attachmentsDubboAttachmentMatchOther information attached to the request, such as HSF request context, Eagleeye context, etc.NO
headersmap<string, StringMatch>Common request protocol fields, etc., such as interface name, method name, timeout, etc.NO
thresholdDoubleMatchThe machines in the called subset list account for the threshold of the entire hostNO

Since there may be duplication of fields among headers, attachmes, and methods, TODO further refines

DubboMethodMatch

DubboMethodMatch is used to achieve method matching

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - route detail:
    - match:
      - method: #DubboMethodRequest
        - name_match:
          argc:
          args:
          argp:
          headers:
  • property description
FieldTypeDescriptionRequired
name_matchStringMatchmatch the calling method name in the requestYES
argcintThe number of parameters matching the requestNO
argsDubboMethodArg[]is an array of DubboMethodArg type, indicating the condition that each parameter value needs to meetNO
argpStringMatch[]match request parameter typeNO
headersmap<string, StringMatch>reservedNO

DubboMethodArg

DubboMethodArg is used to match method parameters

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - route detail:
    - match:
      -method:
        - args: #DubboMethodArg
          - index:
            str_value:
            type:
            num_value:
            bool_value:
            reserve:
  • property description
FieldTypeDescriptionRequired
indexuint32The position of the matching parameter, the index field starts from 1 (that is, the $index parameter)YES
typestringThe type of the matching parameter, taking the string type of java as an example, the value of this field is java.lang.String, and the default value of this field is java.lang.StringYES
str_valueListStringMatchThe value of the matching parameter, parsed according to $type ListStringMatcher: match java.lang.String)NO
num_valueListDoubleMatchNumeric type matchNO
bool_valueBoolMatchbool value type matchNO
reservereserveComplex type matching, not defined for nowNO

DubboAttachmentMatch

DubboAttachmentMatch is used to fully match any object

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - route detail:
    - match:
      - attachments: #DubboAttachmentMatch
          eagleeyecontext:
          dubbo context:
  • property description
FieldTypeDescriptionRequired
eagleeyecontextmap<string, StringMatch>eagleeye contextNO
dubbocontextmap<string, StringMatch>Dubbo request contextNO

ListStringMatch

ListStringMatch is a set of StringMatch collections, any StringMatch matches

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - route detail:
    - match:
      -method:
        - args:
          - index: 1
            str_value: #ListStringMatch
              oneof:
              - regex: "*abc*"
              - exact: parameter-1
  • property description
FieldTypeDescriptionRequired
oneofStringMatch[]matches if any StringMatch matchesNO

StringMatch

StringMatch is used to describe string matching rules

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - service: #StringMatch
    - exact: org.apache.dubbo.demoService:1.0.0
    - prefix: org.apache.dubbo.hello
    - regex: org.apache.dubbo.*Service:2.0.0
  • property description
FieldTypeDescriptionRequired
exactstring (oneof)exact matchNO
prefixstring (oneof)prefix matchNO
regexstring (oneof)regular matchNO
noemptystring (oneof)non-empty character matchNO
emptystring (oneof)empty character matchNO

ListDoubleMatch

ListDoubleMatch is a set of DoubleMatch collections, any DoubleMatch match matches the parameters

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - route detail:
    - match:
      -method:
        - args:
          - index: 1
            type: java.lang.Double
            num_value: #ListDoubleMatch
              oneof:
              - range:
                  start: 1
                  end: 100
                  
  • property description
FieldTypeDescriptionRequired
oneofDoubleMatch[]matches if any DoubleMatch matchesNO

DoubleMatch

DoubleMatch is used to match values of type int, long, double

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - route detail:
    - match:
      -method:
        - args:
          - index: 1
            type: java.lang.Double
            num_value:
              oneof: #DoubleMatch[]
              - range:
                  start: 1
                  end: 100
              #Assume that the parameter value of the currently input Double type is x,
              #The meaning of the following expression is: x%mode=exact,
              #That is, it matches only when x%10=6
              - exact: 6
                mode: 10
                  
  • property description
FieldTypeDescriptionRequired
exactdouble(oneof)exact value matchNO
rangeDoubleRangeMatch(oneof)value range matchingNO
modedoubleModulo operation, it needs to be configured together with the above two semanticsNO

DoubleRangeMatch

DoubleRangeMatch is to match the range of double values

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - route detail:
    - match:
      -method:
        - args:
          - index: 1
            type: java.lang.Double
            num_value:
              oneof:
              - range: #DoubleRangeMatch
                  start: 1.2
                  end: 1000.5
                  
  • property description
FieldTypeDescriptionRequired
startdoublevalue greater than or equal toYES
enddoublevalue less thanYES

BoolMatch

BoolMatch is used to match true, false exactly

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - route detail:
    - match:
      -method:
        - args:
          - index: 1
            type: java.lang.Boolean
            bool_value: #BoolMatch
              - exact: true
  • property description
FieldTypeDescriptionRequired
exactbool(oneof)true, false, exact match

ObjectMatch (not implemented)

ObjectMatch for an exact match on any object

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - route detail:
    - match:
      -method:
        - args:
          - index: 1
            type: java.lang.String
            str_value:
              oneof:
              - regex: "*abc*"
              - exact: parameter-1
  • property description
FieldTypeDescriptionRequired
typestringThe type of the matching parameter, taking the string type of java as an example, the value of this field is java.lang.String, and the default value of this field is java.lang.StringYES
str_valueListStringMatchThe value of the matching parameter, parsed according to $type ListStringMatcher: match java.lang.String)NO
num_valueListDoubleMatchNO
bool_valueBoolMatchNO

DubboRouteDestination

DubboRouteDestination is used to describe the strategy of traffic to the destination address

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - route detail:
    - route: #DubboRouteDestination
        destination:
        weight: 50
  • property description
FieldTypeDescriptionRequired
destinationDubboDestinationrouting destination DestinationYES
weightintrouting weightNO

DubboDestination

DubboDestination is used to describe the destination address of routing traffic

  • Example of use
apiVersion: service.dubbo.apache.org/v1alpha1
kind: VirtualService
metadata:
  name: demo/StandardRouter
spec:
  hosts:
  dubbo:
  - route detail:
    - route: #DubboRouteDestination
        destination:
          host:
          subnet:
          port:
          fallback:
  • property description
FieldTypeDescriptionRequired
hoststringThe corresponding key value in the registry, now it is the interface nameYES
subsetstringaddress listYES
portintport numberYES
fallbackDubboDestinationanother address list for fallbackNO

Last modified January 2, 2023: Enhance en docs (#1798) (95a9f4f6c)