--- title: Istio 流量治理:VirtualService、DestinationRule 与灰度发布实战 keywords: - Istio - VirtualService - DestinationRule - 熔断 - 灰度发布 description: 使用 Istio 的 VirtualService 与 DestinationRule 进行路由分流、灰度发布与熔断,提供可执行清单。 categories: - 文章资讯 - 科技资讯 --- # Istio 流量治理:VirtualService、DestinationRule 与灰度发布实战 ## 版本子集与灰度发布 ```yaml apiVersion: networking.istio.io/v1beta1 kind: DestinationRule metadata: name: web spec: host: web subsets: - name: v1 labels: version: v1 - name: v2 labels: version: v2 trafficPolicy: outlierDetection: consecutive5xx: 7 interval: 5s baseEjectionTime: 30s maxEjectionPercent: 50 ``` ```yaml apiVersion: networking.istio.io/v1beta1 kind: VirtualService metadata: name: web spec: hosts: - web.default.svc.cluster.local http: - route: - destination: host: web subset: v1 weight: 90 - destination: host: web subset: v2 weight: 10 ``` ## 验证与监控 - 逐步调整权重并观察错误率与时延 - 使用 K8s 与 Istio 仪表盘查看子集命中与驱逐情况 ## 总结 通过子集与权重路由可安全实施灰度发布,配合异常驱逐实现故障隔离与自愈。

发表评论 取消回复