路由级熔断 部署httpbin apiVersion: v1 kind: ServiceAccount metadata: name: httpbin namespace: foo apiVersion: v1 kind: Service metadata: name: httpbin namespace: foo labels: app: httpbin service: httpbin spec: ports: name: http port: 8000 targetPort: 80 selector: app: httpbin apiVersion: apps/v1 kind: Deployment metadata: name: httpbin namespace: foo spec: replicas: 1 selector: matchLabels: app: httpbin version: v1 template: metadata: labels: app: httpbin version: v1 spec: serviceAccountName: httpbin containers: image: registryvpccrshuadong1.cnspinternal.ctyun.cn/library/httpbin:latest imagePullPolicy: IfNotPresent name: httpbin ports: containerPort: 80 开始验证 创建CTGCircuitBreaker,例如 apiVersion: istio.ctyun.cn/v1beta1 kind: CTGCircuitBreaker metadata: name: routerbreaker namespace: istiosystem spec: configs: breakerconfig: breakduration: 10s customresponse: body: "hello, break!rn" headertoadd: xenvoycircuitbreak: "true" statuscode: 499 errorpercent: value: 60 maxslowrequests: 10 minrequestamount: 3 slowrequestrt: 0.1s windowsize: 11s match: vhost: name: bookinfo.com route: headermatch: exactmatch: value1 name: key1 exactmatch: value2 name: key2 namematch: httpbinroutename1 workloadSelector: labels: istio: ingressgateway 这条熔断规则作用于httpbinroutename1,对应VirtualService中的路由名。spec具体字段说明如下: 字段名 类型 字段说明 configs []CircuitBreakerConfig 熔断配置,详细字段下文说明。 workloadSelector WorkloadSelector 通用的workloadSelector,以labels过滤所作用的workload。