主流发布方案:
• 蓝绿发布
• 灰度发布(金丝雀发布)
• 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
从三个监控获取的信息:
閱讀更多 愛踢人生 的文章