The canary-header plug-in adds specified headers to a configured percentage of requests and re-matches routes, enabling percentage-based canary releases without requiring clients to carry a canary header.
Fields
|
Configuration item |
Data type |
Required |
Default value |
Description |
|
|
array of object |
Yes |
- |
The headers to add and their weights. |
The following table describes the fields in the weighted_headers array.
|
Configuration item |
Data type |
Required |
Default value |
Description |
|
|
string |
Yes |
- |
The header key to add. |
|
|
string |
Yes |
- |
The header value to add. |
|
|
number |
Yes |
- |
The weight for this header. Unit: %. The total weight of all headers cannot exceed 100. |
If the total weight of all headers is less than 100, the remaining percentage of requests are forwarded without an added header.
Configuration examples
Global configuration
The following example adds the x-higress-canary:gray header to 30% of requests and the x-higress-canary:base header to the remaining 70%.
weighted_headers:
- added_key: x-higress-canary
added_value: gray
weight: 30
- added_key: x-higress-canary
added_value: base
weight: 70
The following example adds the x-higress-canary:gray header to 30% of requests. The remaining 70% are forwarded without an added header.
weighted_headers:
- added_key: x-higress-canary
added_value: gray
weight: 30
Enable the plug-in for specific routes or domain names
When the route-a route is matched, the x-higress-canary:gray header is added to 30% of requests and the x-higress-canary:base header to the remaining 70%. Routes are then re-matched. For example, if a route named route-a-gray uses the x-higress-canary:gray header for matching, 30% of route-a requests match route-a-gray, enabling percentage-based canary releases.
# Use the _rules_ field to configure fine-grained rules.
_rules_:
# Rule 1: Match a route name.
- _match_route_:
- route-a
weighted_headers:
- added_key: x-higress-canary
added_value: gray
weight: 30
- added_key: x-higress-canary
added_value: base
weight: 70
# Rule 2: Match a domain name.
- _match_domain_:
- "*.example.com"
weighted_headers:
- added_key: x-custom-header
added_value: gray
weight: 30
- added_key: x-custom-header
added_value: blue
weight: 30
- added_key: x-custom-header
added_value: base
weight: 40