add canary-weight-total annotation (#6338)
This commit is contained in:
parent
6163231ef6
commit
5cff197bc5
7 changed files with 71 additions and 5 deletions
|
|
@ -32,6 +32,7 @@ type canary struct {
|
|||
type Config struct {
|
||||
Enabled bool
|
||||
Weight int
|
||||
WeightTotal int
|
||||
Header string
|
||||
HeaderValue string
|
||||
HeaderPattern string
|
||||
|
|
@ -59,6 +60,11 @@ func (c canary) Parse(ing *networking.Ingress) (interface{}, error) {
|
|||
config.Weight = 0
|
||||
}
|
||||
|
||||
config.WeightTotal, err = parser.GetIntAnnotation("canary-weight-total", ing)
|
||||
if err != nil {
|
||||
config.WeightTotal = 100
|
||||
}
|
||||
|
||||
config.Header, err = parser.GetStringAnnotation("canary-by-header", ing)
|
||||
if err != nil {
|
||||
config.Header = ""
|
||||
|
|
|
|||
|
|
@ -896,6 +896,7 @@ func (n *NGINXController) createUpstreams(data []*ingress.Ingress, du *ingress.B
|
|||
upstreams[defBackend].NoServer = true
|
||||
upstreams[defBackend].TrafficShapingPolicy = ingress.TrafficShapingPolicy{
|
||||
Weight: anns.Canary.Weight,
|
||||
WeightTotal: anns.Canary.WeightTotal,
|
||||
Header: anns.Canary.Header,
|
||||
HeaderValue: anns.Canary.HeaderValue,
|
||||
HeaderPattern: anns.Canary.HeaderPattern,
|
||||
|
|
|
|||
|
|
@ -111,10 +111,15 @@ type Backend struct {
|
|||
// alternative backend
|
||||
// +k8s:deepcopy-gen=true
|
||||
type TrafficShapingPolicy struct {
|
||||
// Weight (0-100) of traffic to redirect to the backend.
|
||||
// e.g. Weight 20 means 20% of traffic will be redirected to the backend and 80% will remain
|
||||
// with the other backend. 0 weight will not send any traffic to this backend
|
||||
// Weight (0-<WeightTotal>) of traffic to redirect to the backend.
|
||||
// e.g. <WeightTotal> defaults to 100, weight 20 means 20% of traffic will be
|
||||
// redirected to the backend and 80% will remain with the other backend. If
|
||||
// <WeightTotal> is set to 1000, weight 2 means 0.2% of traffic will be
|
||||
// redirected to the backend and 99.8% will remain with the other backend.
|
||||
// 0 weight will not send any traffic to this backend
|
||||
Weight int `json:"weight"`
|
||||
// The total weight of traffic (>= 100). If unspecified, it defaults to 100.
|
||||
WeightTotal int `json:"weightTotal"`
|
||||
// Header on which to redirect requests to this backend
|
||||
Header string `json:"header"`
|
||||
// HeaderValue on which to redirect requests to this backend
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue