Examples of application of article BookInfo deployment Istio and configure access routing and other functions. Before proceeding, you must first complete the " OpenShift 4 of the command to create a Service Mesh environment ."
Article Directory
Micro deploy service applications BookInfo
Applied Micro service deployment
- Creating bookinfo-red project
$ BOOKINFO_PROJECT=bookinfo-red
$ oc new-project $BOOKINFO_PROJECT
$ ISTIO_RELEASE=$(curl --silent https://api.github.com/repos/istio/istio/releases/latest |grep -Po '"tag_name": "\K.*?(?=")')
- The bookinfo-red in project added ServiceMeshMemberRoll.
$ oc get smmr default -n istio-system -o json --export | jq '.spec.members += ["'"$BOOKINFO_PROJECT"'"]' | oc apply -n istio-system -f -
$ oc get smmr default -n istio-system -o jsonpath={.spec.members}
[default bookinfo-red]
- Bookinfo deploy application-related micro-services, and resources.
$ oc apply -n $BOOKINFO_PROJECT -f https://raw.githubusercontent.com/istio/istio/${ISTIO_RELEASE}/samples/bookinfo/platform/kube/bookinfo.yaml
- The micro-injected into the sidecar service deployment.
for deployment in $(oc get deployments -o jsonpath='{.items[*].metadata.name}' -n $BOOKINFO_PROJECT);do
oc -n $BOOKINFO_PROJECT patch deployment $deployment -p '{"spec":{"template":{"metadata":{"annotations":{"sidecar.istio.io/inject": "true"}}}}}'
done
- Creating application access gateway.
$ oc apply -n $BOOKINFO_PROJECT -f https://raw.githubusercontent.com/istio/istio/${ISTIO_RELEASE}/samples/bookinfo/networking/bookinfo-gateway.yaml
$ oc get gateway.networking.istio.io
NAME AGE
bookinfo-gateway 19m
- Continuous access to the gateway through the application, the application returns to confirm the results. Note bookinfo-gateway gateway of foreign exposure route is istio-system project.
$ GATEWAY_URL=$(oc -n istio-system get route istio-ingressgateway -o jsonpath='{.spec.host}')
$ while true; do curl -s http://${GATEWAY_URL}/productpage | grep -o "<title>.*</title>"; done
<title>Simple Bookstore App</title>
<title>Simple Bookstore App</title>
<title>Simple Bookstore App</title>
...
Micro-tracking service requests
- Monitoring Kiali get console access URL
$ oc -n istio-system get route kiali -o jsonpath='{.spec.host}'
kiali-istio-system.apps-crc.testing
- Access Kiali console in your browser. Graph bookinfo-red into the project from the Overview, and then view the micro-services access path.
Configuring micro dynamic routing service
All traffic sent to the micro-service v1
- Execute commands, create Istio route target (destination-rule-all.yaml) and routing policy (virtual-service-all-v1.yaml).
$ oc apply -n $BOOKINFO_PROJECT -f https://raw.githubusercontent.com/liuxiaoyu-git/redhat-service-mesh-demo/master/04-Dynamic-Routing/destination-rule-all.yaml
$ oc apply -n $BOOKINFO_PROJECT -f https://raw.githubusercontent.com/liuxiaoyu-git/redhat-service-mesh-demo/master/04-Dynamic-Routing/virtual-service-all-v1.yaml
- View flow through the micro-service version of the Kiali, in which case all traffic flows on the v1 version of the micro-services.
The traffic by 4: reviews sent to a service micro v1 and v2
- Run the flow rate in accordance with the 4: v1 and v2 sent to serving micro reviews
$ oc apply -n $BOOKINFO_PROJECT -f https://raw.githubusercontent.com/liuxiaoyu-git/redhat-service-mesh-demo/master/04-Dynamic-Routing/virtual-service-reviews-80-20.yaml
- At this point in Kiali you can see there is a request flow into the v2 version of the micro-service reviews.
V2 send all traffic to the micro-service reviews
- Execute commands, all the requests sent to the v2 version of the micro-service reviews
$ oc apply -n $BOOKINFO_PROJECT -f https://raw.githubusercontent.com/liuxiaoyu-git/redhat-service-mesh-demo/master/04-Dynamic-Routing/virtual-service-reviews-v2.yaml
- Check in at Kiali
The route request browser type
- Execute commands, according to the micro-service reviews
$ oc apply -n $BOOKINFO_PROJECT -f https://raw.githubusercontent.com/liuxiaoyu-git/redhat-service-mesh-demo/master/04-Dynamic-Routing/virtual-service-reviews-chrome.yaml
- Execute the following command, and general analog Chrome browser in a 1: 1 ratio to continue to access the application.
$ while true; do sleep 1; curl -A "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36" -s http://${GATEWAY_URL}/productpage | grep -o "color=\"red\""; curl -s http://${GATEWAY_URL}/productpage | grep -o "color=\"black\"";done
- Check in Kiali, make sure route to the v2 and v3 versions reviews micro service request is the same.
Different versions of the same micro-service traffic load
- The flow is distributed to all versions of the current micro-services.
oc apply -n $BOOKINFO_PROJECT -f https://raw.githubusercontent.com/pichuang/redhat-service-mesh-demo/master/05-Traffic-Government/destination-rule-all.yaml
oc apply -n $BOOKINFO_PROJECT -f https://raw.githubusercontent.com/pichuang/redhat-service-mesh-demo/master/05-Traffic-Government/virtual-service-reviews-all.yaml
2. Run the request sent in rotation in three versions reviews micro-services.
$ oc apply -n $BOOKINFO_PROJECT -f https://raw.githubusercontent.com/pichuang/redhat-service-mesh-demo/master/05-Traffic-Government/destination-rule-reviews-round-robin.yaml
3. Run the request randomly distributed in three versions reviews micro-services.
$ oc apply -n $BOOKINFO_PROJECT -f https://raw.githubusercontent.com/pichuang/redhat-service-mesh-demo/master/05-Traffic-Government/destination-rule-reviews-random.yaml