{"id":32994,"date":"2023-03-17T12:32:37","date_gmt":"2023-03-17T12:32:37","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=32994"},"modified":"2025-01-13T12:15:23","modified_gmt":"2025-01-13T12:15:23","slug":"knative-tutorials-knative-service-traffic-management-traffic-routing-examples","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/knative-tutorials-knative-service-traffic-management-traffic-routing-examples\/","title":{"rendered":"Knative Tutorials: Knative Service: Traffic management: Traffic routing examples"},"content":{"rendered":"\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Routing and managing traffic by using the Knative CLI<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">You can use the following kn CLI command to split traffic between revisions:<\/h3>\n\n\n\n<p>$ kn service update &#8211;traffic =<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">For example, to split traffic for a Service named example, by sending 80% of traffic to the Revision green and 20% of traffic to the Revision blue, you could run the following command:<\/h3>\n\n\n\n<p>$ kn service update example-service &#8211;traffic green=80 &#8211;traffic blue=20<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">It is also possible to add tags to Revisions and then split traffic according to the tags you have set:<\/h3>\n\n\n\n<p>$ kn service update example &#8211;tag revision-0001=green &#8211;tag @latest=blue<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The @latest tag means that blue resolves to the latest Revision of the Service. The following example sends 80% of traffic to the latest Revision and 20% to a Revision named v1.<\/h3>\n\n\n\n<p>$ kn service update example-service &#8211;traffic @latest=80 &#8211;traffic v1=20<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>The following example shows a traffic spec where 100% of traffic is routed to the latestRevision of the Service. Under status you can see the name of the latest Revision that latestRevision was resolved to:<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/d7a44d125dfd7b83ec9f3372b88c8fb7.js\"><\/script>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>The following example shows a traffic spec where 100% of traffic is routed to the current Revision, and the name of that Revision is specified as example-service-1. The latest ready Revision is kept available, even though no traffic is being routed to it:<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/058b29be3501105805e68008d9f638ff.js\"><\/script>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>The following example shows how the list of Revisions in the traffic spec can be extended so that traffic is split between multiple Revisions. This example sends 50% of traffic to the current Revision, example-service-1, and 50% of traffic to the candidate Revision, example-service-2:<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/devops-school\/09829f99af92eb65ebff817da1d0f3e0.js\"><\/script>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n","protected":false},"excerpt":{"rendered":"<p>Routing and managing traffic by using the Knative CLI You can use the following kn CLI command to split traffic between revisions: $ kn service update &#8211;traffic = For example,&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[8921],"tags":[],"class_list":["post-32994","post","type-post","status-publish","format-standard","hentry","category-knative"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32994","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=32994"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32994\/revisions"}],"predecessor-version":[{"id":32995,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/32994\/revisions\/32995"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=32994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=32994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=32994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}