GithubHelp home page GithubHelp logo

Comments (11)

stefanprodan avatar stefanprodan commented on May 27, 2024 2

The header match conditions have been merged into the spec, next is the TrafficSplit API spec update 🎉

from smi-spec.

stefanprodan avatar stefanprodan commented on May 27, 2024

As suggested by @nicholasjackson this is how an A/B test could look using HTTP routes:

---
kind: HTTPRouteGroup
metadata:
  name: website-routes
matches:
- name: external-users
  pathRegex: ".*"
  methods: ["*"]
  headers:
   - user-agent: ".*Chrome.*"
   - cookie: "^(.*?;)?(canary=enabled)(;.*)?$"
- name: internal-users
  pathRegex: ".*"
  methods: ["*"]
  headers:
   - x-canary: "enabled"
- name: all-users
  pathRegex: ".*"
  methods: ["*"]
---
kind: TrafficTarget
metadata:
  name: website-canary
destination:
  kind: TrafficSplit
  name: website-canary
specs:
- kind: HTTPRouteGroup
  name: website-routes
  matches:
  - external-users
  - internal-users
---
kind: TrafficTarget
metadata:
  name: website-primary
destination:
  kind: TrafficSplit
  name: website-primary
specs:
- kind: HTTPRouteGroup
  name: website-routes
  matches:
  - all-users
---
kind: TrafficSplit
metadata:
  name: website-primary
spec:
  service: website-primary
  backends:
  - service: website-primary
    weight: 100
  - service: website-canary
    weight: 0
---
kind: TrafficSplit
metadata:
  name: website-canary
spec:
  service: website-canary
  backends:
  - service: website-primary
    weight: 0
  - service: website-canary
    weight: 100

I'm in favour of the first proposal, this is not only highly verbose but makes automation of an A/B test harder. For example Flagger would have to create the HTTPRouteGroups and TrafficTargets, that means users will have to add all routes to the Canary spec or the routes will overwritten by Flagger. Another issue is that the routes approach needs two apex domains and having a priority field for the routes.

from smi-spec.

michelleN avatar michelleN commented on May 27, 2024

@stefanprodan thanks so much for going through the exercise. The more I thought about it yesterday, the more I appreciated the first approach coming from a UX perspective and it's nice to have all the traffic split functionality defined in one place like you mentioned. Even if we do header matching somewhere else eventually, this pattern of the match section is simple enough to repeat.

from smi-spec.

grampelberg avatar grampelberg commented on May 27, 2024

Oh, I hadn't even considered using TrafficTarget for anything other than ACLs. Here's what I was thinking:

kind: HTTPRouteGroup
metadata:
  name: the-routes
matches:
- name: metrics
  pathRegex: "/metrics"
---
kind: TrafficSplit
metadata:
  name: website
spec:
  service: website
  matches:
  - kind: HTTPRouteGroup
    name: the-routes
  backends:
  - service: website-primary
    weight: 0
  - service: website-canary
    weight: 100

Things I like

  • HTTPRouteGroup was originally intended to be auto-generated from a swagger spec. While it isn't required, it is nice to be able to have a single definition of what the traffic for a service should look like that can be referenced and validated as part of an admission controller.

  • Using matches allows for different types of protocols, imagine using this for gRPC for example.

  • Makes it explicit what the split matches. Instead of a bunch of different backends, there's a single thing that matches and does the distribution.

  • Looking down the road, this approach allows for doing things like only redirecting idempotent requests (selecting all the GET routes in a HTTPRouteGroup) without duplicating definitions everywhere.

Open Questions

  • How do users reason about two traffic splits that match the same apex service? Is this a valid use case? Should the admission controller manage this behavior?

  • I've not tried to add headers into HTTPRouteGroup. It'd be possible to either add them there or create a separate resource (neither way feels great right now).

from smi-spec.

stefanprodan avatar stefanprodan commented on May 27, 2024

I don’t see how your example covers the use case I’ve described. I see a single backend list and that can’t accommodate the A/B test.

from smi-spec.

grampelberg avatar grampelberg commented on May 27, 2024

In this instance, all traffic that matches /metrics will go to website-canary. All other traffic will go to website-primary. Ignoring the headers piece, which I definitely need to spend more time thinking about, it seems like it matches your use case? What am I missing?

from smi-spec.

stefanprodan avatar stefanprodan commented on May 27, 2024

There is no primary 100% in the definition. How you decide where the traffic goes that doesn’t match the conditions?

from smi-spec.

stefanprodan avatar stefanprodan commented on May 27, 2024

Ah I got it. The website ClusterIP should point to the primary not the TrafficSplit apex.

from smi-spec.

grampelberg avatar grampelberg commented on May 27, 2024

Whatever was happening beforehand. I'm trying to do the additive approach, eg. this TrafficSplit will only be evaluated if it matches the conditions - otherwise, everything behaves the way it did before the TrafficSplit was created.

You could also do:

kind: HTTPRouteGroup
metadata:
  name: the-routes
matches:
- name: metrics
  pathRegex: "/metrics"
---
kind: TrafficSplit
metadata:
  name: website
spec:
  service: website
  matches:
  - kind: HTTPRouteGroup
    name: the-routes
  backends:
  - service: website-primary
    weight: 0
  - service: website-canary
    weight: 100
---
kind: TrafficSplit
metadata:
  name: website
spec:
  service: website
  backends:
  - service: website-primary
    weight: 100
  - service: website-canary
    weight: 0

This raises a couple other questions though (which are also relevant for your original proposal) - how do we highlight hierarchy? Is it just done by specificity?

fwiw, given your confusion, this may not be the best suggestion =)

from smi-spec.

stefanprodan avatar stefanprodan commented on May 27, 2024

I thought that the apex replaces the Kubernetes service, but even if the TrafficSplit is additive I think merging can’t be avoided if we want to allow per route splitting. For example, if I want to route /login 10% to canary and logout 20% to canary I’ll have to create two splits with the same apex. I think that the only way to avoid merging is to allow pairs of conditions/backends in a single TrafficSplit.

from smi-spec.

grampelberg avatar grampelberg commented on May 27, 2024

Yeah, my point is that we're gonna have to tackle merging no matter what.

from smi-spec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.