Istio BookInfo Application测试案例
文章目录
【注意】最后更新于 January 17, 2020,文中内容可能已过时,请谨慎使用。
Start the application services
-
Change directory to the root of the Istio installation.
-
The default Istio installation uses automatic sidecar injection. Label the namespace that will host the application with istio-injection=enabled:
$ kubectl label namespace default istio-injection=enabled
|
|
- Deploy your application using the kubectl command:
$ kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
|
|
The command launches all four services shown in the bookinfo application architecture diagram. All 3 versions of the reviews service, v1, v2, and v3, are started.
In a realistic deployment, new versions of a microservice are deployed over time instead of deploying all versions simultaneously.
- Confirm all services and pods are correctly defined and running:
|
|
and
|
|
- To confirm that the Bookinfo application is running, send a request to it by a curl command from some pod, for example from ratings:
$ kubectl exec -it $(kubectl get pod -l app=ratings -o jsonpath=’{.items[0].metadata.name}') -c ratings – curl productpage:9080/productpage | grep -o “.*”
Determine the ingress IP and port
Now that the Bookinfo services are up and running, you need to make the application accessible from outside of your Kubernetes cluster, e.g., from a browser. An Istio Gateway is used for this purpose.
- Define the ingress gateway for the application:
$ kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
- Confirm the gateway has been created:
|
|
-
Follow these instructions to set the INGRESS_HOST and INGRESS_PORT variables for accessing the gateway. Return here, when they are set.
-
Set GATEWAY_URL:
$ export GATEWAY_URL=$INGRESS_HOST:$INGRESS_PORT
Confirm the app is accessible from outside the cluster
To confirm that the Bookinfo application is accessible from outside the cluster, run the following curl command:
|
|
You can also point your browser to http://$GATEWAY_URL/productpage to view the Bookinfo web page. If you refresh the page several times, you should see different versions of reviews shown in productpage, presented in a round robin style (red stars, black stars, no stars), since we haven’t yet used Istio to control the version routing.
Apply default destination rules
Before you can use Istio to control the Bookinfo version routing, you need to define the available versions, called subsets, in destination rules.
Run the following command to create default destination rules for the Bookinfo services:
-
If you did not enable mutual TLS, execute this command:
Choose this option if you are new to Istio and are using the demo configuration profile.
$ kubectl apply -f samples/bookinfo/networking/destination-rule-all.yaml
- If you
did
enable mutual TLS, execute this command:
$ kubectl apply -f samples/bookinfo/networking/destination-rule-all-mtls.yaml
Wait a few seconds for the destination rules to propagate.
You can display the destination rules with the following command:
$ kubectl get destinationrules -o yaml
What’s next
You can now use this sample to experiment with Istio’s features for traffic routing, fault injection, rate limiting, etc. To proceed, refer to one or more of the Istio Tasks, depending on your interest. Configuring Request Routing is a good place to start for beginners.
Cleanup
When you’re finished experimenting with the Bookinfo sample, uninstall and clean it up using the following instructions:
- Delete the routing rules and terminate the application pods
$ samples/bookinfo/platform/kube/cleanup.sh
- Confirm shutdown
|
|