Sandbox Matching
Overview
The match field of a RouteGroup permits matching Sandboxes for inclusion in the routing context defined by a RouteGroup.
Only Sandboxes in the same cluster as the RouteGroup may be matched, and Sandboxes are matched according to their labels.
label Match Example
Using label in match will match a sandbox whose labels contain a key-value
pair (k,v) where k is equal to the value of label.key and v matches
the glob in the value of label.value.
Here are some examples:
# routegroup
spec:
  cluster: staging
  match:
    label:              # checks whether there exists a label such that ...
      key: feature      # key is equal to 'feature' (this is not a glob); and
      value: x-*        # key matches the glob 'x-*'
---
# matching sandbox
spec:
  cluster: staging
  labels:
    team: plumbing      # it doesn't matter if there are other labels
    feature: x-backend  # matches because key is 'feature' and value matches glob 'x-*'
---
# non-matching sandbox
spec:
  cluster: staging
  labels:
    team: plumbing
  forks: ...
all Match Example
all match matches a sandbox if all of the associated list of label matchers match.
Here are some examples:
# routegroup
spec:
  cluster: staging
  match:
    all:
    - label:
        key: feature
        value: x-*
    - label:
        key: team
        value: dev-*
---
# matching sandbox
spec:
  cluster: staging
  labels:
    team: dev-plumbing
    feature: x-backend
---
# non-matching sandbox
spec:
  cluster: staging
  labels:
    team: test-plumbing # wrong team value
    feature: x-backend
  forks: ...
any Match Example
any match matches a sandbox if any of the associated list of label matchers match.
Here are some examples:
# routegroup
spec:
  cluster: staging
  match:
    any:
    - label:
        key: feature
        value: x-*
    - label:
        key: team
        value: qe-*  # include sandboxes baking in QE
---
# matching sandbox 1
spec:
  cluster: staging
  labels:
    team: dev-plumbing
    feature: x-backend
---
# matching sandbox 2
spec:
  cluster: staging
  labels:
    team: qe-frontend
---
# non-matching sandbox 1
spec:
  cluster: staging
  labels:
    team: test-plumbing # wrong team value
    feature: y-backend  # wrong feature
  forks: ...
---
# non-matching sandbox 2
spec:
  cluster: staging
  labels: null