Pro rata distribution traffic
This section To configure traffic distribution policy Fontend micro services, in order to control and distribute to the destination Backend_v1 Backend_v2 access traffic.
- In Kiali console enter Services-> backend, click Action, select Create Weighted Routing drop-down menu.
- Weight will backend_v1 in the Create Weighted Routing dialog box is set to 80. Then open Hide Advanced Options, the Add LoadBalance set to ON, and make sure LoadBalancer is ROUND_ROBIN strategy. Finally, click the Create button. The system creates Destination Rule and Virtual Service objects depending on the configuration.
- Above creation DestinationRule and VirtualService in Kiali console can also be done by the following command.
$ oc apply -f istio-files/destination-rule-backend-v1-v2.yml -n my-istio-app
$ oc apply -f istio-files/virtual-service-backend-v1-v2-80-20.yml -n my-istio-app
- In Kiali enter Istio Config, you can view VirtualService and DestinationRul configuration.
- Continue with the following script, see the difference when used in the Graph.
$ scripts/run-50.sh
6. Edit DestinationRule, change the weight ratio. Save and then run the previous step, send test request and view the results.
$ oc get DestinationRule -n my-istio-app
NAME HOST AGE
backend backend 20h
$ oc edit DestinationRule backend -n my-istio-app
Traffic Mirroring
The request made at the same time the average traffic distribution between Backend_v1 and Backend_v2, the request will be sent to Backend_v3 micro mirror service. This scenario is typically used for application testing or traffic monitoring.
- Deployment Backend_v3 micro-services.
$ oc apply -f ocp/backend-v3-deployment.yml -n my-istio-app
$ oc apply -f ocp/backend-v3-service.yml -n my-istio-app
- VirtualService execute command to create a new configuration backend-virtual-service, delete the original backend of VirtualService.
$ oc apply -f istio-files/virtual-service-backend-v1-v2-mirror-to-v3.yml -n my-istio-app
$ oc delete VirtualService backend -n my-istio-app
Where virtual-service-backend-v1-v2-mirror-to-v3.yml the following content.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: backend-virtual-service
spec:
hosts:
backend
http:
route:
- destination:
host: backend
subset: v1
weight: 80
- destination:
host: backend
subset: v2
weight: 20
mirror:
host: backend-v3
- Continue with the following script.
$ scripts/run-50.sh
- Log in to view Backend_v3 another new window you confirm backend_v3 can receive each request through traffic mirroring.
$ oc logs -f <backend_v3 pod> -c backend -n my-istio-app
- Finally, delete the relevant Istio Policy configuration, leaving only three micro-services.
$ oc delete -f istio-files/virtual-service-backend-v1-v2-mirror-to-v3.yml -n my-istio-app
$ oc delete -f istio-files/destination-rule-backend-v1-v2.yml -n my-istio-app
$ oc delete -f ocp/backend-v3-deployment.yml -n my-istio-app
$ oc delete -f ocp/backend-v3-service.yml -n my-istio-app