OpenShift run BookInfo 4 of Istio of micro-service applications

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 ."

Micro deploy service applications BookInfo

Applied Micro service deployment

  1. 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.*?(?=")')
  1. 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]
  1. 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
  1. 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
  1. 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
  1. 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

  1. Monitoring Kiali get console access URL
$ oc -n istio-system get route kiali -o jsonpath='{.spec.host}'
kiali-istio-system.apps-crc.testing
  1. Access Kiali console in your browser. Graph bookinfo-red into the project from the Overview, and then view the micro-services access path.
    Here Insert Picture Description

Configuring micro dynamic routing service

All traffic sent to the micro-service v1

  1. 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
  1. View flow through the micro-service version of the Kiali, in which case all traffic flows on the v1 version of the micro-services.
    Here Insert Picture Description

The traffic by 4: reviews sent to a service micro v1 and v2

  1. 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
  1. At this point in Kiali you can see there is a request flow into the v2 version of the micro-service reviews.
    Here Insert Picture Description

V2 send all traffic to the micro-service reviews

  1. 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
  1. Check in at Kiali
    Here Insert Picture Description

The route request browser type

  1. 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
  1. 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
  1. Check in Kiali, make sure route to the v2 and v3 versions reviews micro service request is the same.
    Here Insert Picture Description

Different versions of the same micro-service traffic load

  1. 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

Here Insert Picture Description
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

Here Insert Picture Description
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

Here Insert Picture Description

Published 54 original articles · won praise 0 · Views 1104

Guess you like

Origin blog.csdn.net/weixin_43902588/article/details/103770958