rollout support A/B Testing API

Signed-off-by: liheng.zms <liheng.zms@alibaba-inc.com>
This commit is contained in:
liheng.zms 2022-09-22 19:46:36 +08:00
parent 113527e6f3
commit 4724ba2bf3
3 changed files with 130 additions and 1 deletions

View File

@ -116,9 +116,44 @@ type CanaryStep struct {
// Pause defines a pause stage for a rollout, manual or auto
// +optional
Pause RolloutPause `json:"pause,omitempty"`
// MetricsAnalysis *RolloutAnalysis `json:"metricsAnalysis,omitempty"`
// Matches define conditions used for matching the incoming HTTP requests to canary service.
// Each match is independent, i.e. this rule will be matched if **any** one of the matches is satisfied.
Matches []RouteMatch `json:"matches,omitempty"`
}
type RouteMatch struct {
// Headers specifies HTTP request header matchers. Multiple match values are
// ANDed together, meaning, a request must match all the specified headers
// to select the route.
// +kubebuilder:validation:MaxItems=16
Headers []HeaderMatch `json:"headers"`
}
// HeaderMatch describes how to select a route by matching request
// headers.
type HeaderMatch struct {
// Type specifies how to match against the value of the header.
// +optional
// +kubebuilder:default=Exact
Type *HeaderMatchType `json:"type,omitempty"`
// Name is the name of the HTTP Header to be matched. Name matching MUST be
// case insensitive.
Name string `json:"name"`
// Value is the value of HTTP Header to be matched.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=4096
Value string `json:"value"`
}
// +kubebuilder:validation:Enum=Exact;RegularExpression
type HeaderMatchType string
// HeaderMatchType constants.
const (
HeaderMatchExact HeaderMatchType = "Exact"
HeaderMatchRegularExpression HeaderMatchType = "RegularExpression"
)
// RolloutPause defines a pause stage for a rollout
type RolloutPause struct {
// Duration the amount of time to wait before moving to the next step.

View File

@ -187,6 +187,13 @@ func (in *CanaryStep) DeepCopyInto(out *CanaryStep) {
**out = **in
}
in.Pause.DeepCopyInto(&out.Pause)
if in.Matches != nil {
in, out := &in.Matches, &out.Matches
*out = make([]RouteMatch, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CanaryStep.
@ -293,6 +300,26 @@ func (in *HTTPRouteInfo) DeepCopy() *HTTPRouteInfo {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *HeaderMatch) DeepCopyInto(out *HeaderMatch) {
*out = *in
if in.Type != nil {
in, out := &in.Type, &out.Type
*out = new(HeaderMatchType)
**out = **in
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HeaderMatch.
func (in *HeaderMatch) DeepCopy() *HeaderMatch {
if in == nil {
return nil
}
out := new(HeaderMatch)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *IngressInfo) DeepCopyInto(out *IngressInfo) {
*out = *in
@ -697,6 +724,28 @@ func (in *RolloutStrategy) DeepCopy() *RolloutStrategy {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *RouteMatch) DeepCopyInto(out *RouteMatch) {
*out = *in
if in.Headers != nil {
in, out := &in.Headers, &out.Headers
*out = make([]HeaderMatch, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RouteMatch.
func (in *RouteMatch) DeepCopy() *RouteMatch {
if in == nil {
return nil
}
out := new(RouteMatch)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ServiceInfo) DeepCopyInto(out *ServiceInfo) {
*out = *in

View File

@ -108,6 +108,51 @@ spec:
items:
description: CanaryStep defines a step of a canary workload.
properties:
matches:
description: Matches define conditions used for matching
the incoming HTTP requests to canary service. Each
match is independent, i.e. this rule will be matched
if **any** one of the matches is satisfied.
items:
properties:
headers:
description: Headers specifies HTTP request header
matchers. Multiple match values are ANDed together,
meaning, a request must match all the specified
headers to select the route.
items:
description: HeaderMatch describes how to select
a route by matching request headers.
properties:
name:
description: Name is the name of the HTTP
Header to be matched. Name matching MUST
be case insensitive.
type: string
type:
default: Exact
description: Type specifies how to match
against the value of the header.
enum:
- Exact
- RegularExpression
type: string
value:
description: Value is the value of HTTP
Header to be matched.
maxLength: 4096
minLength: 1
type: string
required:
- name
- value
type: object
maxItems: 16
type: array
required:
- headers
type: object
type: array
pause:
description: Pause defines a pause stage for a rollout,
manual or auto