Canary Deployments

Using advanced load-balancing, target weights can be adjusted granularly, allowing for a smooth, controlled canary release.

Using a very simple two target example:

  1. # first target at 1000
  2. curl -X POST http://localhost:8001/upstreams/address.v2.service/targets \
  3. --data "target=192.168.34.17:80"
  4. --data "weight=1000"
  1. # second target at 0
  2. curl -X POST http://localhost:8001/upstreams/address.v2.service/targets \
  3. --data "target=192.168.34.18:80"
  4. --data "weight=0"

By repeating the requests, but altering the weights each time, traffic will slowly be routed towards the other target. For example, set it at 10%:

  1. # first target at 900
  2. curl -X POST http://localhost:8001/upstreams/address.v2.service/targets \
  3. --data "target=192.168.34.17:80"
  4. --data "weight=900"
  1. # second target at 100
  2. curl -X POST http://localhost:8001/upstreams/address.v2.service/targets \
  3. --data "target=192.168.34.18:80"
  4. --data "weight=100"

The changes through the Kong Gateway Admin API are dynamic and take effect immediately. No reload or restart is required, and no in progress requests are dropped.