The VirtualService resource is used to configure the routing rules for the traffic. acctually, it is a CRD of istio. The most important parts of this virtualservice are the two services under the http field. The implementation of the rollout controller will automatically adjust the weight of traffic forwarding according to the degree of rollout.
apiVersion:networking.istio.io/v1alpha3 kind:VirtualService metadata: name:rollouts-demo spec: gateways: -rollouts-demo-gateway# bind the gateway hosts: -rollouts-demo.local# HTTP host header, help to route the traffic http: -name:primary# this is an usefully for canary deployment route: -destination: host:rollouts-demo-stable# this required the service name port: number:80 weight:100 -destination: host:rollouts-demo-canary# this required the service name too port: number:80 weight:0
4.3 service
The service is a k8s resource, it is used to expose the pod to the outside world.
The Rollout resource is a custom resource provided by the argo-rollout controller. It is used to manage the deployment of the application. to explain the Rollout resource, we need to know the canary strategy. the following example is a simple canary strategy. that means is the canary service will receive 25% of the traffic, and the stable service will receive 75% of the traffic with first step. the second step is the canary service will receive 50% of the traffic, and the stable service will receive 50% of the traffic. the last step is the canary service will receive 100% of the traffic, and the stable service will receive 0% of the traffic.
start a tunnel for the istio-ingressgateway service.
1 2 3 4 5 6 7 8 9
$ minikube tunnel [19:58:01] ✅ Tunnel successfully started
📌 NOTE: Please do not close this terminal as this process must stay alive for the tunnel to be accessible ...
❗ The service/ingress istio-ingressgateway requires privileged ports to be exposed: [80 443] 🔑 sudo permission will be asked for it. 🏃 Starting tunnel for service istio-ingressgateway. Password:
from the VirtualService resource, you can find the weight of the canary service is 50, and the weight of the stable service is 50. this value is the second step of the canary strategy.
try to access the rollouts-demo.local in the browser, you can see the result is blue color. because the canary service is 50% of the traffic.