implement canary annotation and alternative backends
Adds the ability to create alternative backends. Alternative backends enable traffic shaping by sharing a single location but routing to different backends depending on the TrafficShapingPolicy defined by AlternativeBackends. When the list of upstreams and servers are retrieved, we then call mergeAlternativeBackends which iterates through the paths of every ingress and checks if the backend supporting the path is a AlternativeBackend. If so, we then iterate through the map of servers and find the real backend that the AlternativeBackend should fall under. Once found, the AlternativeBackend is embedded in the list of VirtualBackends for the real backend. If no matching real backend for a AlternativeBackend is found, then the AlternativeBackend is deleted as it cannot be backed by any server.
This commit is contained in:
parent
5ceb723963
commit
412cd70d3a
18 changed files with 859 additions and 23 deletions
|
|
@ -85,6 +85,30 @@ type Backend struct {
|
|||
UpstreamHashBy string `json:"upstream-hash-by,omitempty"`
|
||||
// LB algorithm configuration per ingress
|
||||
LoadBalancing string `json:"load-balance,omitempty"`
|
||||
// Denotes if a backend has no server. The backend instead shares a server with another backend and acts as an
|
||||
// alternative backend.
|
||||
// This can be used to share multiple upstreams in the sam nginx server block.
|
||||
NoServer bool `json:"noServer"`
|
||||
// Policies to describe the characteristics of an alternative backend.
|
||||
// +optional
|
||||
TrafficShapingPolicy TrafficShapingPolicy `json:"trafficShapingPolicy,omitempty"`
|
||||
// Contains a list of backends without servers that are associated with this backend.
|
||||
// +optional
|
||||
AlternativeBackends []string `json:"alternativeBackends,omitempty"`
|
||||
}
|
||||
|
||||
// TrafficShapingPolicy describes the policies to put in place when a backend has no server and is used as an
|
||||
// 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 int `json:"weight"`
|
||||
// Header on which to redirect requests to this backend
|
||||
Header string `json:"header"`
|
||||
// Cookie on which to redirect requests to this backend
|
||||
Cookie string `json:"cookie"`
|
||||
}
|
||||
|
||||
// HashInclude defines if a field should be used or not to calculate the hash
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue