Skip to content

canary ​

canary splits traffic between middleware chains by weight. Clients can stay on the same variant, and a header or cookie can pick a variant for testing.

yaml
server:
  http:
    middlewares:
      app_v1:
        service:
          loadbalancer:
            servers:
              - url: http://app-v1:8080
      app_v2:
        service:
          loadbalancer:
            servers:
              - url: http://app-v2:8080
      app:
        canary:
          variants:
            - name: stable
              weight: 95
              middlewares:
                - app_v1
            - name: beta
              weight: 5
              middlewares:
                - app_v2
          sticky: {}
          override_header: X-Canary
          variant_header: X-Variant
    routers:
      app:
        path: /*
        middlewares:
          - app
FieldDefaultDescription
variants[].nameRequired. Unique name of the variant.
variants[].weightShare of traffic, relative to the other variants. 0 sends no new traffic.
variants[].middlewaresRequired. Chain that handles the variant, usually ending with service.
stickyKeep a client on the same variant, see below.
override_headerRequest header naming the variant to use, e.g. X-Canary: beta.
override_cookieCookie naming the variant to use.
variant_headerRequest header set to the selected variant, for logs or the upstream.

At least two variants are required and one must have weight. A variant chain that does not answer continues with the middlewares after canary in the router.

Sticky ​

Without sticky each request is assigned at random.

With sticky: {} the variant is stored in a cookie on the first request. When the weight of a stored variant drops to 0, the client is assigned again, so a variant can be drained.

FieldDefaultDescription
sticky.cookieturna_canaryCookie name.
sticky.max_age24hCookie lifetime.
sticky.path/Cookie path.
sticky.domainCookie domain.
sticky.securefalseSend the cookie over HTTPS only.
sticky.keyPick the variant by hashing request parts instead of a cookie.
sticky.trusted_proxiesCIDRs whose forwarding headers are used for the ip key.

sticky.key accepts the parts of rate_limit, e.g. header:X-User-Id or ip. The same key always gets the same variant while the weights stay the same, also across Turna instances and without cookies.

Overrides win over sticky assignment.