Skip to content

rough draft of client policy traffic splitting#2021

Merged
hawkw merged 3 commits intoeliza/client-policy-apifrom
eliza/backendrefs
Dec 6, 2022
Merged

rough draft of client policy traffic splitting#2021
hawkw merged 3 commits intoeliza/client-policy-apifrom
eliza/backendrefs

Conversation

@hawkw
Copy link
Contributor

@hawkw hawkw commented Nov 29, 2022

Depends on #1992

This branch adds a very rough implementation of traffic splitting based
on client policy backends.

Client policy traffic splitting is implemented by moving the existing
traffic split implementation into the linkerd-client-policy crate, and
changing it to operate on the Backend type. The Target struct stored
in a ServiceProfile are replaced with the Backend type, so that the
same traffic split layer can work with a list of backends provided by
either a client policy or a ServiceProfile. The Logical target type
has a new impl of Param<Vec<Backend>> and Param<BackendStream> that
chooses whether to return backends from the client policy discovery or
the ServiceProfile based on whether or not a client policy was
discovered for that logical destination.

This could use some polish, and some cases aren't yet implemented
(client policy backends may be either a named address or a direct
endpoint address, which is not supported by ServiceProfiles, so we'll
need to add additional switching code to handle that case). However,
this should be a decent working steelthread.

@hawkw hawkw requested a review from a team as a code owner November 29, 2022 21:57
@hawkw hawkw marked this pull request as draft December 2, 2022 20:32
@hawkw hawkw marked this pull request as ready for review December 6, 2022 17:04
@hawkw hawkw merged commit ca39313 into eliza/client-policy-api Dec 6, 2022
@hawkw hawkw deleted the eliza/backendrefs branch December 6, 2022 17:05
hawkw added a commit that referenced this pull request Dec 6, 2022
This branch adds a rough draft of a router for selecting client policy
routes. Right now, once a route is selected, it just gets logged as a
demo that route matching works. A follow-up PR will implement HTTPRoute
traffic splitting once a route is matched.

Depends on #2021
hawkw added a commit that referenced this pull request Dec 6, 2022
Depends on #2029

This branch builds on #2021 and #2029 to implement traffic splitting
based on client policy HTTPRoute backends. This is everything necessary
to implement header-based routing using HTTPRoutes, by creating a route
that matches a header and routes to a different `backendRef`. In
addition, this means that we can also now do other forms of traffic
splitting (such as weights) with a HTTPRoute, as well.

The implementation here is pretty straightforward. Currently, the
traffic split middleware that's used for ServiceProfile traffic splits
(and for the top-level list of backends in a client policy lookup, which
are currently not used by the control plane) requires dynamically
updating the split service when the set of backends in the traffic split
changes. In the per-HTTPRoute case, however, this is not necessary, as
the set of HTTPRoutes is being watched by the client policy router, and
the whole stack for a route will be torn down and rebuilt if that
route's definition changes. Therefore, I've factored out the fixed
component of the traffic split (just shifting traffic across a weighted
distribution of services) from the dynamically updating component, so
that the client policy HTTPRoute traffic split can just build and
destroy fixed split middlewares. The dynamically changing traffic split
middleware is now implemented by mutating an inner fixed split
middleware.
hawkw added a commit that referenced this pull request Dec 6, 2022
Depends on #1992

This branch adds a very rough implementation of traffic splitting based
on client policy backends.

Client policy traffic splitting is implemented by moving the existing
traffic split implementation into the `linkerd-client-policy` crate, and
changing it to operate on the `Backend` type. The `Target` struct stored
in a ServiceProfile are replaced with the `Backend` type, so that the
same traffic split layer can work with a list of backends provided by
either a client policy or a ServiceProfile. The `Logical` target type
has a new impl of `Param<Vec<Backend>>` and `Param<BackendStream>` that
chooses whether to return backends from the client policy discovery or
the ServiceProfile based on whether or not a client policy was
discovered for that logical destination.

This could use some polish, and some cases aren't yet implemented
(client policy backends may be either a named address _or_ a direct
endpoint address, which is not supported by ServiceProfiles, so we'll
need to add additional switching code to handle that case). However,
this should be a decent working steelthread.
hawkw added a commit that referenced this pull request Dec 6, 2022
This branch adds a rough draft of a router for selecting client policy
routes. Right now, once a route is selected, it just gets logged as a
demo that route matching works. A follow-up PR will implement HTTPRoute
traffic splitting once a route is matched.

Depends on #2021
hawkw added a commit that referenced this pull request Dec 6, 2022
This branch adds a rough draft of a router for selecting client policy
routes. Right now, once a route is selected, it just gets logged as a
demo that route matching works. A follow-up PR will implement HTTPRoute
traffic splitting once a route is matched.

Depends on #2021
hawkw added a commit that referenced this pull request Dec 6, 2022
Depends on #2029

This branch builds on #2021 and #2029 to implement traffic splitting
based on client policy HTTPRoute backends. This is everything necessary
to implement header-based routing using HTTPRoutes, by creating a route
that matches a header and routes to a different `backendRef`. In
addition, this means that we can also now do other forms of traffic
splitting (such as weights) with a HTTPRoute, as well.

The implementation here is pretty straightforward. Currently, the
traffic split middleware that's used for ServiceProfile traffic splits
(and for the top-level list of backends in a client policy lookup, which
are currently not used by the control plane) requires dynamically
updating the split service when the set of backends in the traffic split
changes. In the per-HTTPRoute case, however, this is not necessary, as
the set of HTTPRoutes is being watched by the client policy router, and
the whole stack for a route will be torn down and rebuilt if that
route's definition changes. Therefore, I've factored out the fixed
component of the traffic split (just shifting traffic across a weighted
distribution of services) from the dynamically updating component, so
that the client policy HTTPRoute traffic split can just build and
destroy fixed split middlewares. The dynamically changing traffic split
middleware is now implemented by mutating an inner fixed split
middleware.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant