接下來實作一下 Istio 的一些基本功能,如請求路由(Request Routing)、流量轉移(Traffic Shifting)
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
kubectl apply -f samples/bookinfo/networking/bookinfo-gateway.yaml
kubectl apply -f samples/bookinfo/platform/kube/bookinfo.yaml
部署完成後會看到有一下的POD
details-v1-c5b5f496d-28p5c 2/2 Running 0 20h
fortio-deploy-567d78d854-4s59l 2/2 Running 0 19h
httpbin-5446f4d9b4-cb442 2/2 Running 0 19h
productpage-v1-c7765c886-zrnvb 2/2 Running 0 20h
ratings-v1-f745cf57b-qlrvr 2/2 Running 0 20h
reviews-v1-75b979578c-n6rzv 2/2 Running 0 20h
reviews-v2-597bf96c8f-lzg6g 2/2 Running 0 20h
reviews-v3-54c6c64795-tts9j 2/2 Running 0 20h
kubectl apply -f samples/bookinfo/networking/virtual-service-all-v1.yaml
透過瀏覽器連線至http://<kubernetes_host_ip>:31380/productpage 驗證不管如何重新整理都看不到星星評價的頁面,如下圖所示:
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml
透過瀏覽器連線至http://<kubernetes_host_ip>:31380/productpage 驗證在登入jason(無密碼)帳號後,就可以看到有星星評價的頁面,如下圖所示:
kubectl delete -f samples/bookinfo/networking/virtual-service-all-v1.yaml
kubectl apply -f samples/bookinfo/networking/virtual-service-all-v1.yaml
透過瀏覽器連線至http://<kubernetes_host_ip>:31380/productpage 驗證不管如何重新整理都看不到星星評價的頁面,如下圖所示:
kubectl apply -f samples/bookinfo/networking/virtual-service-reviews-v3.yaml
透過瀏覽器連線至http://<kubernetes_host_ip>:31380/productpage 驗證在重新整理後有百分之五十的機會可以看到有紅色星星評價的頁面,如下圖所示:
kubectl delete -f samples/bookinfo/networking/virtual-service-all-v1.yaml
Istio的部分就到此告一段落了...