Traffic Route

TrafficRoute policy allows you to configure routing rules for L4 traffic, i.e. blue/green deployments and canary releases.

To route traffic, Kuma matches via tags that we can designate to Dataplane resources. In the example below, the redis destination services have been assigned the version tag to help with canary deployment. Another common use-case is to add a env tag as you separate testing, staging, and production environments’ services. For the redis service, this TrafficRoute policy assigns a positive weight of 90 to the v1 redis service and a positive weight of 10 to the v2 redis service. Kuma utilizes positive weights in the traffic routing policy, and not percentages. Therefore, Kuma does not check if it adds up to 100. If you want to stop sending traffic to a destination service, change the weight for that service to 0.

On Universal:

  1. type: TrafficRoute
  2. name: route-1
  3. mesh: default
  4. sources:
  5. - match:
  6. service: backend
  7. destinations:
  8. - match:
  9. service: redis
  10. conf:
  11. - weight: 90
  12. destination:
  13. service: redis
  14. version: '1.0'
  15. - weight: 10
  16. destination:
  17. service: redis
  18. version: '2.0'

On Kubernetes:

  1. apiVersion: kuma.io/v1alpha1
  2. kind: TrafficRoute
  3. mesh: default
  4. metadata:
  5. namespace: default
  6. name: route-1
  7. spec:
  8. sources:
  9. - match:
  10. service: backend
  11. destinations:
  12. - match:
  13. service: redis
  14. conf:
  15. - weight: 90
  16. destination:
  17. service: redis
  18. version: '1.0'
  19. - weight: 10
  20. destination:
  21. service: redis
  22. version: '2.0'