主流發佈方案:
• 藍綠髮布
• 灰度發佈(金絲雀發佈)
• A/B Test
• 滾動發佈
10.4.1、基於權重的路由(金絲雀發佈)
任務:
1. 流量全部發送到reviews v1版本(不帶五角星)
2. 將90%的流量發送到reviews v1版本,另外10%的流量發送到reviews v2版本(5個黑色五角星),最後完全切換到v2版本
3. 將50%的流量發送到v2版本,另外50%的流量發送到v3版本(5個紅色五角星)
# cd /root/istio-1.4.2/samples/bookinfo/
# kubectl apply -f networking/virtual-service-all-v1.yaml -n bookinfo
# kubectl apply -f networking/destination-rule-all.yaml -n bookinfo
# kubectl apply -f networking/virtual-service-reviews-90-10.yaml -n bookinfo 90%的流量
# cat networking/virtual-service-reviews-90-10.yaml 50%的流量
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v1
weight: 50
- destination:
host: reviews
subset: v2
weight: 50
# kubectl apply -f networking/virtual-service-reviews-90-10.yaml -n bookinfo
# cat networking/virtual-service-reviews-90-10.yaml 100%的流量V2版本
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: reviews
spec:
hosts:
- reviews
http:
- route:
- destination:
host: reviews
subset: v1
weight: 0
- destination:
host: reviews
subset: v2
weight: 100
# kubectl apply -f networking/virtual-service-reviews-90-10.yaml -n bookinfo
# kubectl apply -f networking/virtual-service-reviews-v2-v3.yaml -n bookinfo
10.4.2、基於請求內容的路由(A/B Test)
任務:
1. 將特定用戶的請求發送到reviews v2版本(5個黑色五
角星),其他用戶則不受影響(v3)
# kubectl apply -f networking/virtual-service-reviews-jason-v2-v3.yaml -n bookinfo
10.5、可視化監控
• 監控指標(Grafana)
• 網格可視化(Kiali)
• 調用鏈跟蹤(Jaeger)
# cat monitor-gateway.yaml
---
# 監控指標
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: grafana-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: grafana
spec:
hosts:
- "grafana.ctnrs.com"
gateways:
- grafana-gateway
http:
- route:
- destination:
host: grafana
port:
number: 3000
---
# 網格可視化 Kiali
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: kiali-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: kiali
spec:
hosts:
- "kiali.ctnrs.com"
gateways:
- kiali-gateway
http:
- route:
- destination:
host: kiali
port:
number: 20001
---
# 調用鏈
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: tracing-gateway
spec:
selector:
istio: ingressgateway
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: tracing
spec:
hosts:
- "tracing.ctnrs.com"
gateways:
- tracing-gateway
http:
- route:
- destination:
host: tracing
port:
number: 80
# kubectl apply -f monitor-gateway.yaml -n istio-system
# for i in {1..100};do curl -I http://192.168.1.14/productpage -H “Host: bookinfo.ctnrs.com”;sleep 1;done
grafana訪問地址:http://grafana.ctnrs.com/
kiali訪問地址:http://kiali.ctnrs.com
用戶: admin 密碼: admin
jaeger訪問地址:http://tracing.ctnrs.com
從三個監控獲取的信息:
閱讀更多 愛踢人生 的文章