Reduce the risk of introducing a new software version in production by slowly rolling out the change to a small subset of users. This plugin also enables roll back to your original upstream service, or shift all traffic to the new version.
Configuration Reference
Example plugin configuration
Parameters
Here's a list of all the parameters which can be used in this plugin's configuration:
Form Parameter | Description |
---|---|
name
required Type: string |
The name of the plugin, in this case canary . |
service.id
Type: string |
The ID of the Service the plugin targets. |
route.id
Type: string |
The ID of the Route the plugin targets. |
consumer.id
Type: string |
The ID of the Consumer the plugin targets. |
enabled
required Type: boolean Default value: true |
Whether this plugin will be applied. |
api_id
Type: string |
The ID of the API the plugin targets.
Note: The API Entity is deprecated in favor of Services since CE 0.13.0 and EE 0.32. |
config.start
|
Future time in seconds since epoch, when the release will start (ignored when percentage is set, or when using whitelist or blacklist) |
config.duration
Default value: 3600
|
The duration of the transition in seconds. (Ignored when the percentage is set or when using whitelist or blacklist) |
config.percentage
|
Fixed % of traffic to be routed to new target, if given overrides |
config.steps
Default value: 1000
|
Number of steps the release should be broken into |
config.upstream_host
|
The target hostname where traffic will be routed. (Required if |
config.upstream_fallback
Default value: false
|
Whether the plugin will fallback to the original upstream if the Canary Upstream doesn’t have at least one healthy target. ( |
config.upstream_port
|
The target port where traffic will be routed. (Required if |
config.upstream_uri
|
The Upstream URI where traffic will be routed. (Required if |
config.hash
Default value: consumer
|
Entity to be used for hashing. Options: consumer, ip, or none. Please make sure when not using none, to properly set the settings for |
Usage
The Canary Release plugin allows you to route traffic to two separate upstream
Services referred to as Service A and Service B. The location of Service A
is defined by the service
entity for the request being proxied. The location
of Service B is defined by the
config.upstream_host
, config.upstream_port
, and/or config.upstream_uri
as
configured on the plugin.
There are 3 modes of operation:
- Set a fixed percentage to be routed to Service B. See parameter
config.percentage
. - Define a whitelist or blacklist group comprised of Consumers with allowed or denied access to Service B. The Consumer-group association can be configured using the ACL plugin.
- Set a period (in linear time) over which the traffic will be transferred
from Service A to Service B. See parameters
config.start
andconfig.duration
.
Determining Where to Route a Request
(This does not apply to whitelisting or blacklisting)
The Canary Release plugin defines a number of “buckets” (config.steps
).
Each of these buckets can be routed to either Service A or Service B.
For example: If you set config.steps
to 100 steps, and percentage
to 10%,
Canary will create 100 “buckets”, 10 of which will be routed to Service B,
while the other 90 will remain routed to Service A.
The config.hash
parameter determines which requests end up in a specific bucket.
When set to consumer
, Canary ensures each Consumer will
consistently end up in the same bucket. The effect is that once a Consumer’s bucket
switches to Service B, it will then always go to
Service B, and will not “flip-flop” between A and B. Alternatively if it is set to
ip
then the same concept applies but on the basis of the originating IP address.
When using either the consumer
or ip
setting, if any specific Consumer or IP
is responsible for more than the average percentage of traffic, the migration
may not be evenly distributed, e.g., if the percentage is set to 50%, then 50% of
either the Consumers or IPs will be rerouted, but not necessarily 50% of the total requests.
When set to none
the requests will be evenly distributed; each bucket
will get the same number of requests, but a Consumer or IP might flip-flop between
Service A and Service B on consecutive requests.
Canary provides an automatic fallback if, for some reason, a Consumer or IP can
not be identified. The fall-back order is be consumer
->ip
->none
.
Finalizing the Canary
Once the Canary is complete, either going to 100% for a percentage-based Canary,
or when the timed Canary has reached 100%, the configuration will need to be updated.
Note: if the plugin is configured on a route
, then all routes for the current
service
must have completed the Canary.
- Update the
service
entity to point to Service B by matching it to the URL as specified byconfig.upstream_host
,config.upstream_uri
, andconfig.upstream_port
. - Remove the Canary plugin with a
DELETE
request.
Removing or disabling the Canary Release plugin before the Canary is complete will instantly switch all traffic to Service A.
Upstream Healthchecks
The configuration item upstream_fallback
uses
Upstream Healthchecks
to skip applying the Canary upstream if it does not have at least one healthy
target. For this configuration to take effect, the following conditions must be met:
- As this configuration relies on Kong’s balancer (and healthchecks),
the name specified in
config.upstream_host
must point to a valid Kong Upstream object - Healthchecks are
enabled in the canary upstream, i.e., the upstream specified in
upstream_host
needs to have healthchecks enabled it. It works with both passive and active healthchecks.