{"id":74,"date":"2022-08-22T09:05:07","date_gmt":"2022-08-22T09:05:07","guid":{"rendered":"https:\/\/rannix.cloud\/?p=74"},"modified":"2022-08-22T10:32:04","modified_gmt":"2022-08-22T10:32:04","slug":"cloud_ingress2","status":"publish","type":"post","link":"https:\/\/rannix.cloud\/index.php\/2022\/08\/22\/cloud_ingress2\/","title":{"rendered":"\u4e91\u539f\u751f\u5e94\u7528\u8d1f\u8f7d\u5747\u8861\u7cfb\u52172: \u5165\u53e3\u6d41\u91cf\u5206\u53d1\u3001\u5bb9\u9519\u4e0e\u9ad8\u53ef\u7528\u8c03\u5ea6"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\" id=\"h1-1-introduction\">1. Introduction<\/h1>\n\n\n\n<p>\u5728\u4e91\u539f\u751f\u5e94\u7528\u8d1f\u8f7d\u5747\u8861\u7cfb\u5217\u7b2c\u4e00\u7bc7\u6587\u7ae0\u300a\u4e91\u539f\u751f\u5e94\u7528\u8d1f\u8f7d\u5747\u8861\u9009\u578b\u6307\u5357\u300b\u4ecb\u7ecd\u4e86\u4e91\u539f\u751f\u5bb9\u5668\u73af\u5883\u7684\u5165\u53e3\u6d41\u91cf\u7ba1\u7406\u4f7f\u7528\u573a\u666f\u4e0e\u89e3\u51b3\u65b9\u6848\uff0c\u7528 Envoy \u4f5c\u4e3a\u6570\u636e\u9762\u4ee3\u7406\uff0c\u642d\u914d Istio \u4f5c\u63a7\u5236\u9762\u7684 Istio Ingress Gateway\uff0c\u5728\u591a\u96c6\u7fa4\u6d41\u91cf\u5206\u53d1\u3001\u5b89\u5168\u3001\u53ef\u89c2\u6d4b\u6027\u3001\u5f02\u6784\u5e73\u53f0\u652f\u6301\u7b49\u65b9\u9762\u7684\u7efc\u5408\u5bf9\u6bd4\u4e2d\uff0c\u662f\u4e91\u539f\u751f\u5e94\u7528\u6d41\u91cf\u7ba1\u7406\u7684\u6700\u4f73\u65b9\u6848\u3002<\/p>\n\n\n\n<p>\u5728\u63a5\u5165\u5c42\uff0c\u6211\u4eec\u9700\u8981\u914d\u7f6e\u8def\u7531\u89c4\u5219\u3001\u6d41\u91cf\u884c\u4e3a\uff08\u8d85\u65f6\u3001\u91cd\u5b9a\u5411\u3001\u91cd\u5199\u3001\u91cd\u8bd5\u7b49\uff09\u3001\u8d1f\u8f7d\u5747\u8861\u7b97\u6cd5\u3001\u65ad\u8def\u5668\u3001\u8de8\u57df\u7b49\u6d41\u91cf\u7ba1\u7406\u89c4\u5219\uff0c\u672c\u6587\u5c06\u57fa\u4e8e Istio Ingress Gateway \u9762\u5411\u5165\u53e3\u6d41\u91cf\u5206\u53d1\u3001\u5bb9\u9519\u4e0e\u9ad8\u53ef\u7528\u8c03\u5ea6\u4ecb\u7ecd\u4e0a\u8ff0\u529f\u80fd\u7684\u539f\u7406\u4e0e\u6f14\u793a\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"h1-2-\"><a><\/a>2. \u7ec4\u4ef6\u4ecb\u7ecd<\/h1>\n\n\n\n<p>Istio Ingress Gateway\uff0c\u53ef\u4f5c\u4e3a Kubernetes \u7684\u4e00\u79cd Ingress Controller&nbsp;<a href=\"https:\/\/kubernetes.io\/docs\/concepts\/services-networking\/ingress-controllers\/\"><\/a><a href=\"https:\/\/kubernetes.io\/docs\/concepts\/services-networking\/ingress-controllers\/\">12<\/a>\uff0c\u7531\u6570\u636e\u9762\uff08Envoy \u7f51\u7edc\u4ee3\u7406&nbsp;<a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/intro\"><\/a><a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/intro\">1<\/a>\uff09\u4e0e\u63a7\u5236\u9762 Istiod&nbsp;<a href=\"https:\/\/istio.io\/latest\/docs\/ops\/deployment\/architecture\/#istiod\"><\/a><a href=\"https:\/\/istio.io\/latest\/docs\/ops\/deployment\/architecture\/#istiod\">13<\/a>\u7ec4\u6210\uff0c\u9ed8\u8ba4\u4ee5 Deployment \u7684\u5f62\u5f0f\u90e8\u7f72 Pod \u81f3 Kubernetes \u96c6\u7fa4\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h2-2-1-\"><a><\/a>2.1 \u670d\u52a1\u53d1\u73b0<\/h2>\n\n\n\n<p>Istio Ingress Gateway \u63a7\u5236\u9762 Istiod \u53ef\u8054\u901a\u5404\u79cd\u670d\u52a1\u53d1\u73b0\u7cfb\u7edf\uff08Kubernetes\uff0cConsul\uff0cDNS\uff09\u83b7\u53d6 endpoints \u4fe1\u606f\uff0c\u6216\u8005\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528 ServiceEntry \u624b\u52a8\u6dfb\u52a0\u670d\u52a1\u4e0e endpoints \u5bf9\u5e94\u4fe1\u606f\u3002\u4ee5\u5e38\u89c1\u7684 Kubernentes \u96c6\u7fa4\u4e3a\u4f8b\uff0cIstiod \u4ece API Server \u83b7\u53d6 Kubernetes Services \u53ca\u5176\u5bf9\u5e94\u7684 endpoints\uff0c\u5bf9\u5e94\u5173\u7cfb\u5b9e\u65f6\u76d1\u6d4b\u4e0e\u81ea\u52a8\u66f4\u65b0\u3002\u83b7\u53d6\u670d\u52a1\u53d1\u73b0\u4fe1\u606f\u540e\uff0cIstiod \u4f1a\u5c06\u5176\u8f6c\u5316\u4e3a\u6570\u636e\u9762\u6807\u51c6\u6570\u636e\u683c\u5f0f\uff0c\u4ee5 Envoy xDS API \u7684\u5f62\u5f0f push \u5230\u5b9e\u9645\u6267\u884c\u6d41\u91cf\u8f6c\u53d1\u64cd\u4f5c\u7684\u6570\u636e\u9762 Envoy \u7f51\u7edc\u4ee3\u7406\u3002<\/p>\n\n\n\n<p>\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0cIstio Ingress Gateway \u7684\u6570\u636e\u9762 Envoy \u662f\u4ee5\u5355\u72ec Pods \u7684\u5f62\u5f0f\u90e8\u7f72\u4e8e Kubernetes \u96c6\u7fa4\uff0c\u53ea\u9700\u4f7f\u7528 Istio \u5357\u5317\u5411\u6d41\u91cf\u7ba1\u7406\u80fd\u529b\u65f6\uff0c<strong>\u65e0\u9700\u5728\u4e1a\u52a1 Pods \u6ce8\u5165 Istio \u6570\u636e\u9762 sidecar<\/strong>\uff0cIngress Gateway \u7684 Envoy Pods \u5373\u53ef\u627f\u8f7d\u5168\u90e8\u5165\u53e3\u6d41\u91cf\u7ba1\u7406\u7684\u80fd\u529b\uff0c\u56e0\u4e3a Istio \u5165\u53e3\u6d41\u91cf\u7ba1\u7406\u7684\u529f\u80fd\u5927\u90e8\u5206\u662f\u5728 Envoy \u7f51\u7edc\u4ee3\u7406\u7684&nbsp;<strong>client \u7aef\uff08Istio Ingress Gateway\uff09\u5b9e\u73b0<\/strong>\u7684\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"2318\" height=\"1324\" src=\"https:\/\/rannix.cloud\/wp-content\/uploads\/2022\/08\/s1-n2-\u670d\u52a1\u53d1\u73b0\u539f\u7406-2.png\" alt=\"\" class=\"wp-image-79\" title=\"s1-n2-\u670d\u52a1\u53d1\u73b0\u539f\u7406 (2).png\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h2-2-2-istio-api-\"><a><\/a>2.2 Istio \u6d41\u91cf\u7ba1\u7406\u6a21\u578b\u53ca API \u4ecb\u7ecd<\/h2>\n\n\n\n<p>Istio \u8bbe\u8ba1\u4e86\u81ea\u5df1\u7684\u6d41\u91cf\u7ba1\u7406 API\uff0c\u4e3b\u8981\u901a\u8fc7 Gateway\uff0cVirtualService\uff0cDestinationRule \u8fd9\u51e0\u4e2a CR\uff08Kubernetes Custom Resource&nbsp;<a href=\"https:\/\/kubernetes.io\/docs\/concepts\/extend-kubernetes\/api-extension\/custom-resources\/\"><\/a><a href=\"https:\/\/kubernetes.io\/docs\/concepts\/extend-kubernetes\/api-extension\/custom-resources\/\">2<\/a>\uff09\u5b9e\u73b0\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Gateway<\/strong>\uff1a\u914d\u7f6e<strong>\u76d1\u542c\u89c4\u5219<\/strong>\u3002\u5305\u62ec\u7aef\u53e3\u3001\u534f\u8bae\u3001host\u3001SSL \u7b49\u3002<\/li><li><strong>VirtualService<\/strong>\uff1a\u914d\u7f6e<strong>\u8def\u7531\u89c4\u5219<\/strong>\u3002\u5305\u62ec\u5339\u914d\u6761\u4ef6\u3001\u6d41\u91cf\u884c\u4e3a\u3001\u8def\u7531\u76ee\u7684\u670d\u52a1\/\u7248\u672c\u7b49\u3002<\/li><li><strong>DestinationRule<\/strong>\uff1a\u914d\u7f6e<strong>\u670d\u52a1\u7248\u672c<\/strong>\u53ca<strong>\u8d1f\u8f7d\u5747\u8861<\/strong>\u3001<strong>\u8fde\u63a5\u6c60<\/strong>\u3001<strong>\u5065\u5eb7\u68c0\u67e5\u7b56\u7565<\/strong>\u3002<\/li><\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"2120\" height=\"1344\" src=\"https:\/\/rannix.cloud\/wp-content\/uploads\/2022\/08\/s1-n2-Istio-\u6d41\u91cf\u7ba1\u7406\u6a21\u578b-1.png\" alt=\"\" class=\"wp-image-80\" title=\"s1-n2-Istio \u6d41\u91cf\u7ba1\u7406\u6a21\u578b (1).png\"\/><\/figure>\n\n\n\n<p>\u6211\u4eec\u53ef\u4ee5\u4e0e\u5b89\u88c5 Istio \u63a7\u5236\u9762\u6240\u5728\u96c6\u7fa4\u7684 API Server \u4ea4\u4e92\uff0c\u63d0\u4ea4\u4e0a\u8ff0 CR\uff0c\u914d\u7f6e\u6d41\u91cf\u7ba1\u7406\u89c4\u5219\u3002Istiod \u4f1a\u4e0e\u8be5\u96c6\u7fa4\u7684 API Server \u4ea4\u4e92\uff0c\u83b7\u53d6 Istio API\uff0c\u5c06\u8fd9\u4e9b\u914d\u7f6e\u8f6c\u5316\u4e3a Envoy \u6570\u636e\u9762\u6807\u51c6\u6570\u636e\u683c\u5f0f\uff0c\u901a\u8fc7 xDS \u63a5\u53e3 push \u81f3\u6570\u636e\u9762\uff08Istio Ingress Gateway\uff09\uff0c\u6570\u636e\u9762\u5373\u53ef\u6839\u636e\u76f8\u5e94\u89c4\u5219\u8f6c\u53d1\u6d41\u91cf\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"h1-3-\"><a><\/a>3. \u5165\u53e3\u6d41\u91cf\u7ba1\u7406\u5b9e\u8df5<\/h1>\n\n\n\n<p>\u4e0b\u9762\u4ee5 Istio Ingress Gateway \u4e3a\u4f8b\u4ecb\u7ecd\u5165\u53e3\u6d41\u91cf\u5206\u53d1\u3001\u5bb9\u9519\u4e0e\u9ad8\u53ef\u7528\u8c03\u5ea6\u7684\u5b9e\u8df5\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h2-3-1-\"><a><\/a>3.1 \u73af\u5883\u51c6\u5907<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u73af\u5883\u51c6\u5907\u53ef\u4ee5\u4f7f\u7528 TCM \u63a7\u5236\u53f0 \u300c\u4e00\u952e\u4f53\u9a8c\u300d\u529f\u80fd\uff0c\u5c06\u81ea\u52a8\u4e3a\u60a8\u51c6\u5907 TCM + 2 \u4e2a\u8de8\u53ef\u7528\u533a Kubernetes \u96c6\u7fa4 + TCM demo \u7684\u521d\u59cb\u73af\u5883\u3002<\/p><\/blockquote>\n\n\n\n<p>\u6211\u4eec\u51c6\u5907\u4e00\u4e2a Istio Ingress Gateway\uff08\u4f7f\u7528\u817e\u8baf\u4e91\u670d\u52a1\u7f51\u683c TCM \u6f14\u793a\uff09 + Kubernetes \u96c6\u7fa4\uff08\u4f7f\u7528\u817e\u8baf\u4e91\u5bb9\u5668\u670d\u52a1 TKE \u6f14\u793a\uff09\u73af\u5883\uff0c\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u670d\u52a1\u7f51\u683c\u5b9e\u4f8b\uff0c\u5e76\u5728\u7f51\u683c\u5b9e\u4f8b\u4e2d\u521b\u5efa Istio Ingress Gateway\uff0c\u7136\u540e\u6dfb\u52a0\u4e00\u4e2a TKE \u96c6\u7fa4\u4f5c\u4e3a\u7f51\u683c\u7684\u670d\u52a1\u53d1\u73b0\u96c6\u7fa4\u3002<\/p>\n\n\n\n<p>\u5728\u96c6\u7fa4\u90e8\u7f72 TCM demo&nbsp;<a href=\"https:\/\/github.com\/Tencent-Cloud-Mesh\/mesh-demo\"><\/a><a href=\"https:\/\/github.com\/Tencent-Cloud-Mesh\/mesh-demo\">3<\/a>\uff0c\u65e0\u9700\u4e3a\u4e1a\u52a1 Pod \u6ce8\u5165 envoy sidecar\u3002\u8be5 demo \u662f\u4e00\u4e2a\u7535\u5546\u7f51\u7ad9\uff0c\u7531\u4e0d\u540c\u8bed\u8a00\u5f00\u53d1\u7684 6 \u4e2a\u5fae\u670d\u52a1\u7ec4\u6210\uff0c\u4ee5\u4e0b\u662f demo \u7684\u5b8c\u6574\u7ed3\u6784\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"660\" height=\"550\" src=\"https:\/\/rannix.cloud\/wp-content\/uploads\/2022\/08\/image-1621593468945.png\" alt=\"\" class=\"wp-image-82\" title=\"image.png\"\/><\/figure>\n\n\n\n<p>\u672c\u6b21\u6f14\u793a\u5165\u53e3\u6d41\u91cf\u7ba1\u7406\u4f1a\u4f7f\u7528 demo \u4e2d\u7684 user\u3001product\u3001cart \u4e09\u4e2a\u5e94\u7528\uff0c\u5c06\u5176\u63d0\u4f9b\u7684 API \u901a\u8fc7 istio- ingressgateway \u66b4\u9732\u4f9b\u5ba2\u6237\u7aef\u8c03\u7528\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1464\" height=\"784\" src=\"https:\/\/rannix.cloud\/wp-content\/uploads\/2022\/08\/s1-n2-ingress-gw-demo-1.png\" alt=\"\" class=\"wp-image-83\" title=\"s1-n2-ingress gw demo (1).png\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h2-3-2-\"><a><\/a>3.2 \u5165\u53e3\u6d41\u91cf\u5206\u53d1<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h3-3-2-1-\"><a><\/a>3.2.1 \u5e94\u7528\u53d1\u5e03<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u4e1a\u52a1\u9700\u8981\u5c06\u591a\u4e2a\u540e\u7aef\u6a21\u5757\u63d0\u4f9b\u7684 API \u66b4\u9732\u4f9b\u5ba2\u6237\u7aef\u8c03\u7528\uff0c\u9700\u8981\u914d\u7f6e\u7f51\u5173\u8def\u7531\u89c4\u5219\uff0c\u5c06\u8bf7\u6c42\u8def\u5f84 \/product \u7684\u6d41\u91cf\u8def\u7531\u81f3 product \u670d\u52a1\uff0c\u5c06 \/cart \u7684\u8bf7\u6c42\u8def\u7531\u81f3 cart \u670d\u52a1\uff0c\u5c06 \/user \u7684\u8bf7\u6c42\u8def\u7531\u81f3 user \u670d\u52a1\u3002<\/p><\/blockquote>\n\n\n\n<p>TCM demo \u4e2d\uff0cproduct \u670d\u52a1\u63d0\u4f9b \/product \u63a5\u53e3\uff0c\u53ef\u83b7\u53d6\u5728\u552e\u5546\u54c1\u5217\u8868\uff1buser \u670d\u52a1\u63d0\u4f9b \/user \u63a5\u53e3\uff0c\u53ef\u83b7\u53d6\u7528\u6237\u4fe1\u606f\uff1bcart \u670d\u52a1\u63d0\u4f9b \/cart \u63a5\u53e3\uff0c\u53ef\u83b7\u53d6\u8d2d\u7269\u8f66\u5546\u54c1\u5217\u8868\u3002\u4e0b\u9762\u6211\u4eec\u914d\u7f6e Istio Ingress Gateway \u6309\u7167\u8bf7\u6c42\u7684\u8def\u5f84\u66b4\u9732\u4e0a\u8ff0\u63a5\u53e3\u3002<\/p>\n\n\n\n<p><strong>1.<\/strong>&nbsp;\u9996\u5148\u6211\u4eec\u901a\u8fc7 kubectl \u83b7\u53d6 Ingress Gateway \u7684 IP\uff0c\u5e76\u914d\u7f6e\u4e3a\u53d8\u91cf&nbsp;<code>$INGRESS_HOST<\/code>\uff0c\u65b9\u4fbf\u540e\u7eed\u76f4\u63a5\u5f15\u7528\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress&#91;0].ip}')<\/code><\/pre>\n\n\n\n<p><strong>2.&nbsp;<\/strong>\u4f7f\u7528 Gateway \u914d\u7f6e Ingress Gateway \u76d1\u542c\u89c4\u5219\uff0c\u5f00\u542f 80 \u7aef\u53e3\uff0cHTTP \u534f\u8bae\uff0c\u6682\u4e0d\u914d\u7f6e SSL\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: networking.istio.io\/v1alpha3<\/code><code>kind: Gateway<\/code><code>metadata:<\/code><code>  name: apis-gw<\/code><code>spec:<\/code><code>  servers:<\/code><code>    - port:<\/code><code>        number: 80<\/code><code>        name: HTTP-80-6wsk<\/code><code>        protocol: HTTP<\/code><code>      hosts:<\/code><code>        - '*'<\/code><code>  selector:<\/code><code>    app: istio-ingressgateway<\/code><code>    istio: ingressgateway<\/code><\/code><\/pre>\n\n\n\n<p><strong>3.&nbsp;<\/strong>\u4f7f\u7528 VirtualService \u914d\u7f6e\u8def\u7531\u89c4\u5219\uff0cgateway \u53c2\u6570\u586b\u5199\u4e0a\u4e00\u6b65\u521b\u5efa\u7684&nbsp;<code>default\/apis-gw<\/code>\uff0chttp \u8def\u7531\u5339\u914d\u89c4\u5219\u5c06 \/product \u7684\u8bf7\u6c42\u8def\u7531\u81f3 product \u670d\u52a1\uff0c\/user \u8def\u7531\u81f3 user \u670d\u52a1\uff0c\/cart \u8def\u7531\u81f3 cart \u670d\u52a1\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: networking.istio.io\/v1alpha3<\/code><code>kind: VirtualService<\/code><code>metadata:<\/code><code>  name: apis-vs<\/code><code>spec:<\/code><code>  hosts:<\/code><code>    - '*'<\/code><code>  gateways:<\/code><code>    - default\/apis-gw<\/code><code>  http:<\/code><code>    - match:<\/code><code>        - uri:<\/code><code>            exact: \/product<\/code><code>      route:<\/code><code>        - destination:<\/code><code>            host: product.base.svc.cluster.local<\/code><code>    - match:<\/code><code>        - uri:<\/code><code>            exact: \/user<\/code><code>      route:<\/code><code>        - destination:<\/code><code>            host: user.base.svc.cluster.local<\/code><code>    - match:<\/code><code>        - uri:<\/code><code>            exact: \/cart<\/code><code>      route:<\/code><code>        - destination:<\/code><code>            host: cart.base.svc.cluster.local<\/code><\/code><\/pre>\n\n\n\n<p><strong>4.&nbsp;<\/strong>\u4f7f\u7528&nbsp;<code>curl<\/code>&nbsp;\u9a8c\u8bc1\u4e0a\u8ff0\u914d\u7f6e\uff0c\u8bf7\u6c42 API \u8fd4\u56de\u7684 JSON \u5b57\u4e32\u4f7f\u7528&nbsp;<code>jq<\/code>&nbsp;\u89e3\u6790\uff0c\u63d0\u53d6\u51fa\u8fd4\u56de\u7684 service \u4fe1\u606f\u3002\u8bf7\u6c42\u5df2\u6309\u7167\u9884\u8bbe\u65b9\u5f0f\u6309\u8def\u5f84\u8def\u7531\u81f3\u4e0d\u540c\u670d\u52a1\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ curl http:\/\/$INGRESS_HOST\/product | jq '.info&#91;0].Service'<\/code><code>...<\/code><code>\"product-v1\"<\/code><code>$ curl http:\/\/$INGRESS_HOST\/cart | jq '.Info&#91;1].Service'<\/code><code>...<\/code><code>\"cart-v1\"<\/code><code>$ curl http:\/\/$INGRESS_HOST\/user | jq '.Info&#91;0].Service'<\/code><code>...<\/code><code>\"user-v1\"<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h3-3-2-2-\"><a><\/a>3.2.2 \u7070\u5ea6\u53d1\u5e03<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u4e1a\u52a1\u9700\u8981\u5347\u7ea7 product \u670d\u52a1\uff0c\u5df2\u7ecf\u5b8c\u6210\u51c6\u5907\u65b0\u7248\u672c\u955c\u50cf\uff0c\u53ef\u4ee5\u5f00\u59cb\u90e8\u7f72\u65b0\u7248\u672c\u7684 pods\u3002\u5e0c\u671b\u670d\u52a1\u7aef\u5728\u5347\u7ea7\u65f6\u9700\u8003\u8651\u7248\u672c\u7684\u5e73\u6ed1\u3001\u65e0\u98ce\u9669\u8fed\u4ee3\uff0c\u6309\u767e\u5206\u6bd4\u8c03\u6574\u6d41\u91cf\u9010\u6b65\u5207\u6362\u81f3\u65b0\u7248\u672c\u670d\u52a1\uff0c\u7070\u5ea6\u9a8c\u8bc1\u65b0\u7248\u672c\u65e0\u95ee\u9898\u540e\u518d\u4e0b\u7ebf\u65e7\u7248\u672c\u3002<\/p><\/blockquote>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u914d\u7f6e Ingress Gateway \u505a product \u670d\u52a1\u7070\u5ea6\u53d1\u5e03\u7684\u6d41\u7a0b\uff1a<\/p>\n\n\n\n<p><strong>1.<\/strong>&nbsp;\u4f7f\u7528 DestinationRule \u5b9a\u4e49 product \u670d\u52a1\u7684\u7248\u672c\uff08subsets\uff09\uff0c\u7528\u6807\u7b7e\u952e\u503c\u5339\u914d\u5373\u53ef\u5b9a\u4e49\u4e00\u4e2a\u670d\u52a1\u5185 subsets \u4e0e endpoints \u5bf9\u5e94\u5173\u7cfb\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: networking.istio.io\/v1alpha3<\/code><code>kind: DestinationRule<\/code><code>metadata:<\/code><code>  name: product<\/code><code>  namespace: base<\/code><code>spec:<\/code><code>  host: product<\/code><code>  subsets:<\/code><code>    - name: v1<\/code><code>      labels:<\/code><code>        version: v1<\/code><code>    - name: v2<\/code><code>      labels:<\/code><code>        version: v2<\/code><code>  exportTo:<\/code><code>    - '*'<\/code><\/code><\/pre>\n\n\n\n<p><strong>2.&nbsp;<\/strong>\u4f7f\u7528 VirtualService \u914d\u7f6e\u7070\u5ea6\u53d1\u5e03\u8def\u7531\u7b56\u7565\uff0c\u53d1\u5e03\u6700\u521d v2 \u7248\u672c\u4e3a 0% \u7684\u6d41\u91cf\uff0cv1 \u7248\u672c 100%\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: networking.istio.io\/v1alpha3<\/code><code>kind: VirtualService<\/code><code>metadata:<\/code><code>  name: apis-vs<\/code><code>spec:<\/code><code>  hosts:<\/code><code>    - '*'<\/code><code>  gateways:<\/code><code>    - default\/apis-gw<\/code><code>  http:<\/code><code>    - match:<\/code><code>        - uri:<\/code><code>            exact: \/product<\/code><code>      route:<\/code><code>        - destination:<\/code><code>            host: product.base.svc.cluster.local<\/code><code>            subset: v2<\/code><code>          weight: 0<\/code><code>        - destination:<\/code><code>            host: product.base.svc.cluster.local<\/code><code>            subset: v1<\/code><code>          weight: 100<\/code><code>    - match:<\/code><code>        - uri:<\/code><code>            exact: \/user<\/code><code>      route:<\/code><code>        - destination:<\/code><code>            host: user.base.svc.cluster.local<\/code><code>    - match:<\/code><code>        - uri:<\/code><code>            exact: \/cart<\/code><code>      route:<\/code><code>        - destination:<\/code><code>            host: cart.base.svc.cluster.local<\/code><\/code><\/pre>\n\n\n\n<p><strong>3.&nbsp;<\/strong>\u6211\u4eec\u628a TCM demo product \u670d\u52a1\u7684 v2 \u7248\u672c\uff08deployment\uff09<a href=\"https:\/\/github.com\/Tencent-Cloud-Mesh\/mesh-demo\/blob\/master\/yamls\/step07-apps-product-v2.yaml\"><\/a><a href=\"https:\/\/github.com\/Tencent-Cloud-Mesh\/mesh-demo\/blob\/master\/yamls\/step07-apps-product-v2.yaml\">5<\/a>&nbsp;\u90e8\u7f72\u5230\u96c6\u7fa4\uff0c\u7136\u540e\u6a21\u62df\u53d1\u8d77 10 \u6b21\u8bf7\u6c42\u8c03\u7528 product \u670d\u52a1\uff0c\u8fd4\u56de\u7ed3\u679c\u8868\u660e\u53d1\u5e03\u6700\u521d\u6240\u6709\u6d41\u91cf\u4ecd\u7136\u662f\u8def\u7531\u5230 v1 \u7248\u672c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ for((i=0;i&lt;10;i++)) do curl http:\/\/$INGRESS_HOST\/product | jq '.info&#91;0].Service'; done<\/code><code>\"product-v1\"<\/code><code>\"product-v1\"<\/code><code>\"product-v1\"<\/code><code>\"product-v1\"<\/code><code>\"product-v1\"<\/code><code>\"product-v1\"<\/code><code>\"product-v1\"<\/code><code>\"product-v1\"<\/code><code>\"product-v1\"<\/code><code>\"product-v1\"<\/code><\/code><\/pre>\n\n\n\n<p><strong>4.&nbsp;<\/strong>\u4fee\u6539 VirtualService\uff0c\u628a product v1 \u548c v2 subset \u7684\u6743\u91cd\u503c\u5206\u522b\u8c03\u6574\u4e3a\uff1a50\uff0c50\u3002\u6a21\u62df\u53d1\u8d77 10 \u6b21\u8bf7\u6c42\u8c03\u7528 product \u670d\u52a1\uff0c\u7ed3\u679c\u5982\u9884\u8bbe\uff0cv2 \u548c v1 \u7248\u672c\u8c03\u7528\u6b21\u6570\u7684\u6bd4\u4f8b\u63a5\u8fd1 1:1\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ for((i=0;i&lt;10;i++)) do curl http:\/\/$INGRESS_HOST\/product | jq '.info&#91;0].Service'; done<\/code><code>\"product-v1\"<\/code><code>\"product-v2\"<\/code><code>\"product-v1\"<\/code><code>\"product-v2\"<\/code><code>\"product-v1\"<\/code><code>\"product-v2\"<\/code><code>\"product-v1\"<\/code><code>\"product-v2\"<\/code><code>\"product-v1\"<\/code><code>\"product-v1\"<\/code><\/code><\/pre>\n\n\n\n<p><strong>5.&nbsp;<\/strong>\u7070\u5ea6\u9a8c\u8bc1\u5b8c\u6210\u540e\uff0c\u4fee\u6539\u7070\u5ea6\u53d1\u5e03\u8def\u7531\u89c4\u5219\uff0c\u4fee\u6539 VirtualService \u8c03\u6574 v1 v2 subset \u6743\u91cd\u5206\u522b\u4e3a\uff1a0\uff0c100\uff0c\u5c06 100% \u8bf7\u6c42 \/product \u7684\u6d41\u91cf\u8def\u7531\u81f3 product v2 \u7248\u672c\u3002\u518d\u6b21\u6a21\u62df\u53d1\u8d77 10 \u6b21\u8bf7\u6c42\u9a8c\u8bc1\uff0c\u6240\u6709\u8bf7\u6c42\u5df2\u88ab\u8def\u7531\u81f3 product v2\uff0c\u7070\u5ea6\u53d1\u5e03\u5b8c\u6210\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ for((i=0;i&lt;10;i++)) do curl http:\/\/$INGRESS_HOST\/product | jq '.info&#91;0].Service'; done<\/code><code>\"product-v2\"<\/code><code>\"product-v2\"<\/code><code>\"product-v2\"<\/code><code>\"product-v2\"<\/code><code>\"product-v2\"<\/code><code>\"product-v2\"<\/code><code>\"product-v2\"<\/code><code>\"product-v2\"<\/code><code>\"product-v2\"<\/code><code>\"product-v2\"<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h3-3-2-3-\"><a><\/a>3.2.3 \u4f1a\u8bdd\u4fdd\u6301<\/h3>\n\n\n\n<p>\u540c\u4e00\u540e\u7aef\u670d\u52a1\u4e00\u822c\u7531\u591a\u4e2a\u5b9e\u4f8b\uff08Pod\uff09\u627f\u8f7d\uff0c\u901a\u5e38\u9700\u8981\u5c06\u5165\u53e3\u6d41\u91cf\u5728\u591a\u4e2a\u540e\u7aef\u5b9e\u4f8b\u8d1f\u8f7d\u5747\u8861\uff08\u4f8b\u5982 product \u670d\u52a1\uff09\u8d1f\u8f7d\u5747\u8861\uff0c\u6b64\u65f6\u914d\u7f6e\u7684\u662f round robin\u3001random \u6216\u6700\u5c0f\u8fde\u63a5\u6570\u7b49\u8d1f\u8f7d\u5747\u8861\u7b97\u6cd5\uff0c\u4fdd\u6301\u591a\u4e2a\u540e\u7aef\u5b9e\u4f8b\u5747\u8861\u5904\u7406\u6d41\u91cf\u3002<br>\u5728\u4e00\u4e9b\u7279\u5b9a\u60c5\u51b5\u4e0b\uff0c\u9700\u8981\u5c06\u6765\u81ea\u540c\u4e00\u7528\u6237\u7684\u8bf7\u6c42\u8def\u7531\u5230\u76f8\u540c\u540e\u7aef\u5b9e\u4f8b\uff0c\u4fdd\u8bc1\u67d0\u4e9b\u9700\u8981\u4f1a\u8bdd\u4fdd\u6301\u7684\u670d\u52a1\uff08\u4f8b\u5982 cart \u8d2d\u7269\u8f66\u670d\u52a1\uff09\u80fd\u591f\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n\n\n\n<p>\u4f1a\u8bdd\u4fdd\u6301\u6709\u4e24\u79cd\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>\u57fa\u4e8e IP \u7684\u7b80\u5355\u4f1a\u8bdd\u4fdd\u6301\uff1a\u6765\u81ea\u540c\u4e00 IP \u5730\u5740\u7684\u8bf7\u6c42\u5224\u5b9a\u4e3a\u540c\u4e00\u7528\u6237\uff0c\u8def\u7531\u81f3\u76f8\u540c\u540e\u7aef\u670d\u52a1\u5b9e\u4f8b\u3002\u5b9e\u73b0\u7b80\u5355\u3001\u65b9\u4fbf\uff0c\u4f46\u65e0\u6cd5\u652f\u6491\u591a\u4e2a\u5ba2\u6237\u7aef\u4f7f\u7528\u4ee3\u7406\u8bbf\u95ee\u540e\u7aef\u670d\u52a1\u7684\u573a\u666f\uff0c\u6b64\u65f6\u540c\u4e00 IP \u5730\u5740\u4e0d\u4ee3\u8868\u540c\u4e00\u7528\u6237\u3002<\/li><li>\u57fa\u4e8e cookie\uff08\u6216\u5176\u4ed6 7 \u5c42\u4fe1\u606f\uff09\u7684\u4f1a\u8bdd\u4fdd\u6301\uff1a\u7528\u6237\u7b2c\u4e00\u6b21\u8bf7\u6c42\u65f6\uff0c\u8fb9\u7f18\u7f51\u5173\u4e3a\u5176\u63d2\u5165 cookie \u5e76\u8fd4\u56de\uff0c\u540e\u7eed\u5ba2\u6237\u7aef\u4f7f\u7528\u6b64 cookie \u8bbf\u95ee\uff0c\u8fb9\u7f18\u7f51\u5173\u6839\u636e cookie \u5c06\u6d41\u91cf\u8d1f\u8f7d\u81f3\u540e\u7aef\u670d\u52a1\u5b9e\u4f8b\u3002<\/li><\/ul>\n\n\n\n<p>Istio Ingress Gateway \u53ef\u8bbe\u7f6e\u57fa\u4e8e IP\u3001cookie\u3001HTTP header \u7684\u4f1a\u8bdd\u4fdd\u6301\uff0c\u4f46\u8be5\u7b56\u7565\u53ea\u5bf9 HTTP \u6d41\u91cf\u751f\u6548\u3002\u4e0b\u9762\u5c06\u914d\u7f6e cart \u670d\u52a1\u7684 IP\u3001cookie \u4e24\u79cd\u4f1a\u8bdd\u4fdd\u6301\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\u3002<\/p>\n\n\n\n<p>\u5982\u4f7f\u7528\u5f00\u6e90 Istio Ingress Gateway + CLB\uff0c\u914d\u7f6e\u8fb9\u7f18\u7f51\u5173\u6d41\u91cf\u7ba1\u7406\u89c4\u5219\u5b58\u5728\u5982\u4e0b\u95ee\u9898\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>\u624b\u52a8\u4fee\u6539\u5173\u8054 Service \u89c4\u5219<\/strong>\uff1a\u4f7f\u7528 Gateway \u914d\u7f6e\u4e86 Ingress Gateway \u7684\u7aef\u53e3\u540e\uff0c\u9700\u8981\u624b\u52a8\u914d\u7f6e Ingress Gateway \u5173\u8054\u7684 LoadBalancer Service \u7684\u7aef\u53e3\u89c4\u5219\u3002<\/li><li><strong>\u65e0\u6cd5\u83b7\u53d6\u771f\u5b9e\u6e90 IP<\/strong>\uff1a\u4f7f\u7528\u9ed8\u8ba4\u5bb9\u5668\u7f51\u7edc\u6a21\u5f0f\u65f6\uff0cistio-ingressgateway \u901a\u8fc7 loadbalancer service \u7684\u65b9\u5f0f\u66b4\u9732\u7ed9\u516c\u7f51\u8bbf\u95ee\uff0c\u6d41\u91cf\u7ecf\u7531 CLB \u5230\u8282\u70b9\u7684 NodePort \u540e\uff0ckube-proxy \u4f1a\u5c06\u539f\u59cb\u8bf7\u6c42\u505a SNAT \u548c DNAT\uff0c\u56e0\u6b64\u8bf7\u6c42\u5230\u8fbe istio-ingressgateway \u65f6\uff0c\u6e90 IP \u5df2\u4e0d\u662f\u771f\u5b9e client IP\u3002<\/li><\/ul>\n\n\n\n<p>\u4f7f\u7528 TCM Ingress Gateway + TKE \u96c6\u7fa4\u5219\u53ef\u907f\u514d\u4e0a\u8ff0\u95ee\u9898\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>TCM \u5df2\u5b9e\u73b0 Gateway \u7aef\u53e3\u914d\u7f6e\u81ea\u52a8\u5316\u540c\u6b65\u81f3 Ingress Gateway \u76f8\u5173 Kubernetes Service \u53ca\u5173\u8054 CLB\uff0c\u6211\u4eec\u4f7f\u7528 Gateway CR \u5373\u53ef\u4e00\u81f4\u5316\u7ba1\u7406 Ingress Gateway \u5b9e\u4f8b\u7684\u7aef\u53e3\u3002<\/li><li>\u53ef\u4ee5\u901a\u8fc7\u6307\u5b9a istio-ingressgateway service \u7684&nbsp;<code>externalTrafficPolicy: Local<\/code>&nbsp;\u6765\u907f\u514d\u6d41\u91cf\u901a\u8fc7 NAT \u5728\u8282\u70b9\u4e4b\u95f4\u8f6c\u53d1\uff0c\u4fdd\u7559\u4e86\u771f\u5b9e client IP\u3002\u540c\u65f6\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0\u6ce8\u89e3&nbsp;<code>service.kubernetes.io\/local-svc-only-bind-node-with-pod: \"true\"<\/code>&nbsp;\u6765\u6307\u5b9a CLB \u540e\u7aef\u53ea\u7ed1\u5b9a\u6709 istio-ingressgateway Pod \u7684\u8282\u70b9\uff0c\u907f\u514d\u56e0\u540e\u7aef\u7ed1\u5b9a\u4e86\u4e0d\u5b58\u5728 Pod \u5b9e\u4f8b\u7684\u8282\u70b9\u5bfc\u81f4\u5065\u5eb7\u68c0\u67e5\u5931\u8d25\u7684\u95ee\u9898\u3002\u4e5f\u53ef\u4ee5\u589e\u52a0\u6ce8\u89e3&nbsp;<code>service.cloud.tencent.com\/local-svc-weighted-balance: \"true\"<\/code>&nbsp;\u8ba9 CLB \u6839\u636e\u540e\u7aef\u8282\u70b9\u4e0a\u7684 Pod \u6570\u91cf\u505a\u52a0\u6743\u8d1f\u8f7d\u5747\u8861\uff0c\u907f\u514d\u56e0\u4e0d\u540c\u8282\u70b9 Pod \u5b9e\u4f8b\u6570\u91cf\u4e0d\u4e00\u5bfc\u81f4\u7684\u8d1f\u8f7d\u4e0d\u5747\u95ee\u9898&nbsp;<a href=\"https:\/\/cloud.tencent.com\/document\/product\/457\/45492\"><\/a><a href=\"https:\/\/cloud.tencent.com\/document\/product\/457\/45492\">6<\/a>\u3002<\/li><\/ul>\n\n\n\n<p><strong>\u57fa\u4e8e IP \u7684\u4f1a\u8bdd\u4fdd\u6301<\/strong>\uff1a<\/p>\n\n\n\n<p><strong>1.<\/strong>&nbsp;Ingress Gateway \u53ef\u83b7\u53d6\u771f\u5b9e client IP \u540e\uff0c\u6211\u4eec\u901a\u8fc7 DestinationRule \u914d\u7f6e cart \u670d\u52a1\u7684\u57fa\u4e8e IP \u7684\u7b80\u5355\u8d1f\u8f7d\u5747\u8861\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: networking.istio.io\/v1alpha3<\/code><code>kind: DestinationRule<\/code><code>metadata:<\/code><code>  name: cart<\/code><code>  namespace: base<\/code><code>spec:<\/code><code>  host: cart<\/code><code>  trafficPolicy:<\/code><code>    loadBalancer:<\/code><code>      consistentHash:<\/code><code>        useSourceIp: true<\/code><code>  exportTo:<\/code><code>    - '*'<\/code><\/code><\/pre>\n\n\n\n<p><strong>2.&nbsp;<\/strong>\u83b7\u53d6 cart \u670d\u52a1\u5f53\u524d\u7684 pods\uff0c\u4e00\u5171\u90e8\u7f72\u4e86 3 \u4e2a pods\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ kubectl get deployment cart -n base<\/code><code>NAME   READY   UP-TO-DATE   AVAILABLE   AGE<\/code><code>cart   3\/3     3            3           4d23h<\/code><\/code><\/pre>\n\n\n\n<p><strong>3.&nbsp;<\/strong>\u6a21\u62df\u53d1\u8d77 10 \u6b21\u8bf7\u6c42 \/cart \u9a8c\u8bc1\uff0c\u83b7\u53d6\u63d0\u4f9b\u8d2d\u7269\u8f66\u670d\u52a1\u7684 pod \u4fe1\u606f\uff0c\u6240\u6709\u8bf7\u6c42\u5747\u88ab\u8def\u7531\u5230\u4e86\u540c\u4e00\u4e2a pod\uff0c\u57fa\u4e8e IP \u8d1f\u8f7d\u5747\u8861\u914d\u7f6e\u6210\u529f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ for((i=0;i&lt;10;i++)) do curl http:\/\/$INGRESS_HOST\/cart | jq '.Info&#91;1].Pod'; done<\/code><code>\"cart-855f9d75ff-x47bq\"<\/code><code>\"cart-855f9d75ff-x47bq\"<\/code><code>\"cart-855f9d75ff-x47bq\"<\/code><code>\"cart-855f9d75ff-x47bq\"<\/code><code>\"cart-855f9d75ff-x47bq\"<\/code><code>\"cart-855f9d75ff-x47bq\"<\/code><code>\"cart-855f9d75ff-x47bq\"<\/code><code>\"cart-855f9d75ff-x47bq\"<\/code><code>\"cart-855f9d75ff-x47bq\"<\/code><code>\"cart-855f9d75ff-x47bq\"<\/code><\/code><\/pre>\n\n\n\n<p><strong>\u57fa\u4e8e cookie \u7684\u4f1a\u8bdd\u4fdd\u6301<\/strong>\uff1a<\/p>\n\n\n\n<p><strong>1.&nbsp;<\/strong>\u4fee\u6539 cart \u670d\u52a1\u7684 DestinationRule\uff0c\u914d\u7f6e\u57fa\u4e8e cookie \u7684\u8d1f\u8f7d\u5747\u8861\u3002cookie name \u4e3a cookie\uff0ccookie \u8fc7\u671f\u65f6\u95f4\u4e3a 900000 ms\uff08900 s\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: networking.istio.io\/v1alpha3<\/code><code>kind: DestinationRule<\/code><code>metadata:<\/code><code>  name: cart<\/code><code>  namespace: base<\/code><code>spec:<\/code><code>  host: cart<\/code><code>  trafficPolicy:<\/code><code>    loadBalancer:<\/code><code>      consistentHash:<\/code><code>        httpCookie:<\/code><code>          name: cookie<\/code><code>          ttl: 900000ms<\/code><code>  exportTo:<\/code><code>    - '*'<\/code><\/code><\/pre>\n\n\n\n<p><strong>2.&nbsp;<\/strong>\u53d1\u8d77\u7b2c\u4e00\u6b21 \/cart \u8bf7\u6c42\uff0c\u83b7\u53d6 Ingress Gateway \u8fd4\u56de\u7684 cookie ID \u53ca pod \u4fe1\u606f\uff0c\u4f7f\u7528\u8be5 cookie ID \u6a21\u62df\u53d1\u8d77 10 \u6b21 \/cart \u8bf7\u6c42\uff0c\u7b2c\u4e00\u6b21\u8bf7\u6c42\u548c\u540e\u7eed 10 \u6b21\u8bf7\u6c42\uff0c\u6d41\u91cf\u5747\u88ab\u8def\u7531\u5230\u4e86\u540c\u4e00\u4e2a pod\uff08\u5728\u672c\u4f8b\u4e2d\u662f cart-855f9d75ff-dqg6b\uff09\uff0c\u57fa\u4e8e cookie \u7684\u8d1f\u8f7d\u5747\u8861\u914d\u7f6e\u751f\u6548\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ curl http:\/\/$INGRESS_HOST\/cart -i<\/code><code>...<\/code><code>set-cookie: cookie=\"bc0e96c66ff8994b\"; Max-Age=900; HttpOnly<\/code><code>...<\/code><code>Pod\":\"cart-855f9d75ff-dqg6b\"<\/code><code>...<\/code><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ for((i=0;i&lt;10;i++)) do curl http:\/\/$INGRESS_HOST\/cart -b 'cookie=bc0e96c66ff8994b' | jq '.Info&#91;1].Pod'; done<\/code><code>\"cart-855f9d75ff-dqg6b\"<\/code><code>\"cart-855f9d75ff-dqg6b\"<\/code><code>\"cart-855f9d75ff-dqg6b\"<\/code><code>\"cart-855f9d75ff-dqg6b\"<\/code><code>\"cart-855f9d75ff-dqg6b\"<\/code><code>\"cart-855f9d75ff-dqg6b\"<\/code><code>\"cart-855f9d75ff-dqg6b\"<\/code><code>\"cart-855f9d75ff-dqg6b\"<\/code><code>\"cart-855f9d75ff-dqg6b\"<\/code><code>\"cart-855f9d75ff-dqg6b\"<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h2-3-3-\"><a><\/a>3.3 \u5bb9\u9519<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h3-3-3-1-\"><a><\/a>3.3.1 \u8fde\u63a5\u6c60\u7ba1\u7406<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u8fde\u63a5\u6c60\u662f\u4fdd\u6301\u5206\u5e03\u5f0f\u7cfb\u7edf\uff08\u670d\u52a1\u5316\u5e94\u7528\uff09\u7a33\u5b9a\u7684\u91cd\u8981\u914d\u7f6e\u3002\u5206\u5e03\u5f0f\u7cfb\u7edf\u4e2d\u5176\u4e2d\u4e00\u4e2a\u670d\u52a1\u56e0\u8bf7\u6c42\u6570\u66b4\u589e\u800c\u6709\u6545\u969c\u98ce\u9669\u65f6\uff0c\u5feb\u901f\u8fd4\u56de\u5931\u8d25\u4fe1\u606f\u5c3d\u5feb\u5c06\u538b\u529b\u65bd\u52a0\u7ed9\u4e0b\u6e38\u670d\u52a1\u80fd\u6709\u6548\u907f\u514d\u6574\u4e2a\u7cfb\u7edf\u53d1\u751f\u96ea\u5d29\u3002\u6211\u4eec\u53ef\u901a\u8fc7\u8fde\u63a5\u6c60\u4e3a\u6709\u9700\u8981\u7684\u670d\u52a1\u914d\u7f6e TCP\/HTTP \u7684\u8fde\u63a5\u6570\/\u8bf7\u6c42\u6570\u9608\u503c\uff0c\u8fbe\u5230\u9608\u503c\u540e\u62d2\u7edd\u5904\u7406\u65b0\u589e\u6d41\u91cf\u8fd4\u56de\u9519\u8bef\u4fe1\u606f\uff0c\u80fd\u6709\u6548\u4fdd\u62a4\u670d\u52a1\u8fd0\u884c\u7684\u7a33\u5b9a\u6027&nbsp;<a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/circuit_breaking\"><\/a><a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/circuit_breaking\">7<\/a>\u3002<\/p><\/blockquote>\n\n\n\n<p>\u4e0b\u9762\u6211\u4eec\u914d\u7f6e user \u670d\u52a1\u7684\u8fde\u63a5\u6c60\uff1a<\/p>\n\n\n\n<p><strong>1.&nbsp;<\/strong>\u9996\u5148\u6211\u4eec\u90e8\u7f72\u4e00\u7ec4 curl pods \uff0830 \u4e2a\uff09\u6a21\u62df\u5411 user \u670d\u52a1\u53d1\u8d77\u5e76\u53d1\u8bf7\u6c42\uff0c\u53d7\u5404 pod \u8fd0\u884c\u73af\u5883\u5f71\u54cd\uff0c\u5b9e\u9645\u5e76\u53d1\u91cf\u5e94\u8be5 &lt; 30\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: apps\/v1<\/code><code>kind: Deployment<\/code><code>metadata:<\/code><code>  labels:<\/code><code>    k8s-app: curl<\/code><code>    qcloud-app: curl<\/code><code>  name: curl<\/code><code>  namespace: default<\/code><code>spec:<\/code><code>  replicas: 30<\/code><code>  selector:<\/code><code>    matchLabels:<\/code><code>      k8s-app: curl<\/code><code>      qcloud-app: curl<\/code><code>  template:<\/code><code>    metadata:<\/code><code>      labels:<\/code><code>        k8s-app: curl<\/code><code>        qcloud-app: curl<\/code><code>    spec:<\/code><code>      containers:<\/code><code>      - args:<\/code><code>        - -c<\/code><code>        - while true; do curl http:\/\/175.24.254.210\/user; done<\/code><code>        command:<\/code><code>        - \/bin\/sh<\/code><code>        image: docker.io\/byrnedo\/alpine-curl<\/code><code>        imagePullPolicy: IfNotPresent<\/code><code>        name: curl<\/code><\/code><\/pre>\n\n\n\n<p><strong>2.&nbsp;<\/strong>\u4f7f\u7528 DestinationRule \u914d\u7f6e user \u670d\u52a1\u7684\u8fde\u63a5\u6c60\uff0c\u4e3a\u65b9\u4fbf\u89c2\u5bdf\u6548\u679c\uff0c\u6211\u4eec\u914d\u7f6e http1 \u7684\u6700\u5927\u8bf7\u6c42\u7b49\u5f85\u6570\u4e3a 1\uff0chttp2 \u7684\u6700\u5927\u8bf7\u6c42\u6570\u4e3a 1\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: networking.istio.io\/v1alpha3<\/code><code>kind: DestinationRule<\/code><code>metadata:<\/code><code>  name: user<\/code><code>  namespace: base<\/code><code>spec:<\/code><code>  host: user<\/code><code>  trafficPolicy:<\/code><code>    connectionPool:<\/code><code>      http:<\/code><code>        http1MaxPendingRequests: 1<\/code><code>        http2MaxRequests: 1<\/code><code>  exportTo:<\/code><code>    - '*'<\/code><\/code><\/pre>\n\n\n\n<p><strong>3.\u00a0<\/strong>\u5728 TCM \u63a7\u5236\u53f0\u67e5\u770b user \u670d\u52a1\u7684\u76d1\u63a7\uff0c\u53ef\u4ee5\u770b\u5230\u914d\u7f6e\u4e86\u8fde\u63a5\u6c60\u540e\uff0c\u5927\u90e8\u5206\u8bf7\u6c42\u88ab\u8fd4\u56de 503 Service Unavailable \u72b6\u6001\u7801\uff0cuser \u670d\u52a1\u8d85\u8f7d\u914d\u7f6e\u6210\u529f\uff0cDestinationRule \u8fde\u63a5\u6c60\u914d\u7f6e\u8d77\u5230\u4e86\u5f88\u597d\u7684\u4fdd\u62a4\u670d\u52a1\u7aef\u7a33\u5b9a\u6027\u7684\u4f5c\u7528\u3002<\/p>\n\n\n\n<p><br><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"334\" class=\"wp-image-84\" style=\"width: 1000px;\" src=\"https:\/\/rannix.cloud\/wp-content\/uploads\/2022\/08\/image-1621839233204.png\" alt=\"\"><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h3-3-3-2-\"><a><\/a>3.3.2 \u5065\u5eb7\u68c0\u67e5<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u5f53\u540e\u7aef\u670d\u52a1\u5b9e\u4f8b\uff08Pod\uff09\u5728\u5904\u7406\u6d41\u91cf\u8fc7\u7a0b\u4e2d\u53d1\u751f\u6545\u969c\u65f6\uff08\u8fde\u7eed\u8fd4\u56de\u9519\u8bef\uff0c\u6210\u529f\u7387\u964d\u4f4e\u5230\u9608\u503c\u4e4b\u4e0b\u7b49\uff09\uff0cIngress Gateway \u9700\u8981\u53ef\u4ee5\u914d\u7f6e\u5c06\u6545\u969c\u7684 endpoints \u4ece\u5065\u5eb7\u8d1f\u8f7d\u5747\u8861\u6c60\u4e2d\u5254\u9664\u7684\u7b56\u7565\uff0c\u4fdd\u8bc1\u5ba2\u6237\u7aef\u8c03\u7528\u53ef\u4ee5\u7531\u72b6\u6001\u6b63\u5e38\u7684\u540e\u7aef\u670d\u52a1\u5b9e\u4f8b\u5904\u7406\u3002<br>\u53e6\u5916\uff0c\u5730\u57df\u611f\u77e5\u8d1f\u8f7d\u5747\u8861\u529f\u80fd\u4e5f\u9700\u8981\u5f00\u542f\u5f02\u5e38\u68c0\u6d4b\uff0c\u611f\u77e5\u5404\u5730 endpoint \u7684\u5065\u5eb7\u72b6\u6001\u624d\u80fd\u786e\u5b9a\u6d41\u91cf\u8c03\u5ea6\u7b56\u7565\u3002<\/p><\/blockquote>\n\n\n\n<p>Ingress Gateway\uff08envoy\uff09\u7684 Outlier Detection \u662f\u4e00\u79cd\u88ab\u52a8\u5065\u5eb7\u68c0\u67e5\uff0c\u5f53\u6d41\u91cf\u51fa\u73b0\u4e86\u7c7b\u4f3c\u8fde\u7eed 5xx \u9519\u8bef\uff08HTTP\uff09\u3001\u8fde\u63a5\u8d85\u65f6\/\u5931\u8d25\uff08TCP\uff09\u7b49\u884c\u4e3a\u65f6\uff0c\u5c06\u5176\u8bc6\u522b\u4e3a\u79bb\u7fa4\u503c\u4ece\u8d1f\u8f7d\u5747\u8861\u6c60\u4e2d\u5254\u9664\u4e00\u6bb5\u65f6\u95f4&nbsp;<a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/outlier\"><\/a><a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/outlier\">8<\/a>\u3002\u4e0b\u9762\u6211\u4eec\u914d\u7f6e user \u670d\u52a1\u7684\u5065\u5eb7\u68c0\u67e5\u7b56\u7565\u3002<\/p>\n\n\n\n<p><strong>1.&nbsp;<\/strong>\u9996\u5148\u6211\u4eec\u90e8\u7f72\u4e00\u7ec4\u4f1a\u4e3a\u8bf7\u6c42 \/user \u8fd4\u56de 503 \u9519\u8bef\u7684 pods \u4f5c\u4e3a user \u670d\u52a1\u7684\u4e0d\u5065\u5eb7 endpoints\uff0c\u90e8\u7f72\u5b8c\u6210\u540e\u67e5\u770b user \u670d\u52a1\u7684 endpoint \u60c5\u51b5\uff0c\u6709 1 \u4e2a\u5065\u5eb7 user pod\uff0c1 \u4e2a\u4e0d\u5065\u5eb7 user pod\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: apps\/v1<\/code><code>kind: Deployment<\/code><code>metadata:<\/code><code>  name: user-unhealthy<\/code><code>  namespace: base<\/code><code>spec:<\/code><code>  replicas: 1<\/code><code>  selector:<\/code><code>    matchLabels:<\/code><code>      app: user<\/code><code>  template:<\/code><code>    metadata:<\/code><code>      labels:<\/code><code>        app: user<\/code><code>    spec:<\/code><code>      containers:<\/code><code>      - command:<\/code><code>        - sleep<\/code><code>        - \"9000\"<\/code><code>        env:<\/code><code>        - name: POD_NAME<\/code><code>          valueFrom:<\/code><code>            fieldRef:<\/code><code>              apiVersion: v1<\/code><code>              fieldPath: metadata.name<\/code><code>        - name: REGION<\/code><code>          value: shanghai-zone1<\/code><code>        image: docker.io\/busybox<\/code><code>        imagePullPolicy: IfNotPresent<\/code><code>        name: user<\/code><code>        ports:<\/code><code>        - containerPort: 7000<\/code><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ kubectl get deployment -n base user user-unhealthy <\/code><code>NAME             READY   UP-TO-DATE   AVAILABLE   AGE<\/code><code>user             1\/1     1            1           6d19h<\/code><code>user-unhealthy   1\/1     1            1           3d20h<\/code><\/code><\/pre>\n\n\n\n<p><strong>2.&nbsp;<\/strong>\u5f53\u524d\u8fd8\u672a\u914d\u7f6e user \u670d\u52a1\u7684 Outlier Detection\uff08\u88ab\u52a8\u5065\u5eb7\u68c0\u67e5\uff09\uff0c\u4e0d\u5065\u5eb7\u7684 endpoint \u4e0d\u4f1a\u88ab\u4ece\u8d1f\u8f7d\u5747\u8861\u6c60\u4e2d\u5254\u9664\uff0c\u56e0\u6b64\u53d1\u8d77\u7684\u8bf7\u6c42\u90e8\u5206\u6210\u529f\uff08200 OK\uff09\uff0c\u90e8\u5206\u5931\u8d25\uff08503 Service Unavailable\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ for((i=0;i&lt;10;i++)) do curl -I http:\/\/$INGRESS_HOST\/user | grep HTTP\/1.1; done<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 503 Service Unavailable<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 503 Service Unavailable<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 503 Service Unavailable<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 503 Service Unavailable<\/code><code>HTTP\/1.1 503 Service Unavailable<\/code><\/code><\/pre>\n\n\n\n<p><strong>3.&nbsp;<\/strong>\u6211\u4eec\u914d\u7f6e user \u670d\u52a1\u7684 DestinationRule\uff0c\u8bbe\u7f6e Outlier Detection\u3002\u95f4\u9694 10 \u79d2\u505a\u4e00\u6b21\u7edf\u8ba1\uff0c\u4ece\u8d1f\u8f7d\u5747\u8861\u6c60\u4e2d\u5254\u9664\u8fde\u7eed\u9519\u8bef\u6570\u4e3a 3 \u4ee5\u4e0a\u7684 endpoint 30 \u79d2\uff0c\u5141\u8bb8\u6700\u5927\u5254\u9664\u6bd4\u4f8b\u4e3a 100%\uff0c\u6700\u5c0f\u5065\u5eb7\u6bd4\u4f8b\u4e3a 0%\u3002\u5b8c\u6210\u914d\u7f6e\u540e\u6211\u4eec\u6a21\u62df\u8bf7\u6c42 user \u670d\u52a1\uff0c\u6240\u6709\u8bf7\u6c42\u5747\u8fd4\u56de 200 OK\u3002\uff08\u88ab\u52a8\u5065\u5eb7\u68c0\u67e5\uff0c\u9700\u8bf7\u6c42\u8fd4\u56de\u8fde\u7eed\u9519\u8bef\u540e\u624d\u4f1a\u5254\u9664\u4e0d\u5065\u5eb7 endpoint\uff09<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: networking.istio.io\/v1alpha3<\/code><code>kind: DestinationRule<\/code><code>metadata:<\/code><code>  name: user<\/code><code>  namespace: base<\/code><code>spec:<\/code><code>  host: user<\/code><code>  trafficPolicy:<\/code><code>    outlierDetection:<\/code><code>      consecutiveErrors: 3<\/code><code>      interval: 10000ms<\/code><code>      baseEjectionTime: 30000ms<\/code><code>      maxEjectionPercent: 100<\/code><code>      minHealthPercent: 0<\/code><code>  exportTo:<\/code><code>    - '*'<\/code><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ for((i=0;i&lt;10;i++)) do curl -I http:\/\/$INGRESS_HOST\/user | grep HTTP\/1.1; done<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 200 OK<\/code><code>HTTP\/1.1 200 OK<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h3-3-3-3-\"><a><\/a>3.3.3 \u91cd\u5b9a\u5411<\/h3>\n\n\n\n<p>\u5f53\u5e94\u7528\u88ab\u8fc1\u79fb\u5230\u65b0\u7684 URI\uff0c\u540c\u65f6\u53c8\u9700\u8981\u4fdd\u6301\u539f\u6709\u94fe\u63a5\u53ef\u7528\uff0c\u6b64\u65f6\u9700\u8981\u914d\u7f6e HTTP \u91cd\u5b9a\u5411&nbsp;<a href=\"https:\/\/developer.mozilla.org\/zh-CN\/docs\/Web\/HTTP\/Redirections\"><\/a><a href=\"https:\/\/developer.mozilla.org\/zh-CN\/docs\/Web\/HTTP\/Redirections\">9<\/a>\u3002\u91cd\u5b9a\u5411\u53ef\u5e94\u7528\u4e8e\u4ee5\u4e0b\u573a\u666f\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>server \u7aef\u7ef4\u62a4\/\u505c\u673a\u671f\u95f4\u8fc1\u79fb\u5230\u65b0\u7684 URI<\/li><li>\u5f3a\u5236\u4f7f\u7528 HTTPS \u534f\u8bae<\/li><li>\u591a\u57df\u540d\u6269\u5927\u5e94\u7528\u8986\u76d6\u7528\u6237\u4eba\u7fa4<\/li><\/ol>\n\n\n\n<p>\u4e3a\u786e\u4fdd\u901a\u8fc7 Ingress Gateway \u8bbf\u95ee\u540e\u7aef user \u670d\u52a1\u7684\u8bf7\u6c42\u5f3a\u5236\u4f7f\u7528\u66f4\u5b89\u5168\u7684 HTTPS \u534f\u8bae\uff0c\u9700\u8981\u914d\u7f6e Ingress Gateway \u7684 HTTP \u91cd\u5b9a\u5411\u3002<\/p>\n\n\n\n<p>\u4e0b\u9762\u6211\u4eec\u914d\u7f6e\u5f3a\u5236\u4f7f\u7528 HTTPS \u534f\u8bae\u7684\u91cd\u5b9a\u5411\u3002<\/p>\n\n\n\n<p><strong>1.&nbsp;<\/strong>\u7528 Gateway \u914d\u7f6e HTTP \u91cd\u5b9a\u5411\uff0c\u5f3a\u5236\u4f7f\u7528 HTTPS \u534f\u8bae\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: networking.istio.io\/v1alpha3<\/code><code>kind: Gateway<\/code><code>metadata:<\/code><code>  name: apis-gw<\/code><code>spec:<\/code><code>  servers:<\/code><code>    - port:<\/code><code>        number: 80<\/code><code>        name: HTTP-80-h7pv<\/code><code>        protocol: HTTP<\/code><code>      hosts:<\/code><code>        - '*'<\/code><code>      tls:<\/code><code>        httpsRedirect: true<\/code><code>    - port:<\/code><code>        number: 443<\/code><code>        name: HTTPS-443-p1ph<\/code><code>        protocol: HTTPS<\/code><code>      hosts:<\/code><code>        - '*'<\/code><code>      tls:<\/code><code>        mode: SIMPLE<\/code><code>        credentialName: qcloud-$CERTIFICATE_ID<\/code><code>  selector:<\/code><code>    app: istio-ingressgateway<\/code><code>    istio: ingressgateway<\/code><\/code><\/pre>\n\n\n\n<p><strong>2.&nbsp;<\/strong>\u4f7f\u7528 HTTP \u8bf7\u6c42 \/user\uff0c\u8fd4\u56de 301 \u91cd\u5b9a\u5411\u72b6\u6001\u7801\u3002\u5982\u679c\u662f\u5728\u6d4f\u89c8\u5668\u8bbf\u95ee\uff0c\u6536\u5230\u91cd\u5b9a\u5411\u8fd4\u56de\u65f6\uff0c\u4f1a\u91cd\u65b0\u53d1\u8d77\u65b0\u8bf7\u6c42\u5230\u65b0\u7684 URI\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ curl http:\/\/$INGRESS_HOST\/user -I | grep HTTP\/1.1<\/code><code>HTTP\/1.1 301 Moved Permanently<\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h3-3-3-4-\"><a><\/a>3.3.4 \u91cd\u5199<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u4f7f\u7528\u91cd\u5b9a\u5411\uff0c\u5ba2\u6237\u7aef\u53ef\u4ee5\u611f\u77e5\u8bbf\u95ee\u5730\u5740\u7684\u53d8\u5316\uff0c\u5e76\u4e14\u88ab\u91cd\u5b9a\u5411\u7684\u6d41\u91cf\u5b9e\u9645\u4e0a\u53d1\u8d77\u4e86\u4e24\u6b21\u8bf7\u6c42\u624d\u80fd\u6b63\u5e38\u8bbf\u95ee\uff0c\u6709\u4e00\u5b9a\u6027\u80fd\u635f\u8017\u3002\u800c\u91cd\u5199\u5219\u5411\u5ba2\u6237\u7aef\u5c4f\u853d\u4e86\u5730\u5740\u7684\u53d8\u52a8\uff0c\u5b8c\u5168\u7531\u670d\u52a1\u7aef\u8fdb\u884c\u91cd\u5199\u64cd\u4f5c\uff0c\u4f7f\u5ba2\u6237\u7aef\u8bf7\u6c42\u5730\u5740\u4e0e\u670d\u52a1\u7aef\u7ba1\u7406\u89e3\u85d5\u3002<\/p><p>TCM demo \u7684 cart \u670d\u52a1\u63d0\u4f9b\u7684 API \u8d44\u6e90\u53d1\u751f\u4e86\u53d8\u5316\uff0c\u5b9e\u73b0\u4e86 \/clear \u6e05\u7a7a\u8d2d\u7269\u8f66\u7684 API\uff0c\u5e0c\u671b\u5728\u5ba2\u6237\u7aef\u65e0\u611f\u77e5\u7684\u60c5\u51b5\u4e0b\uff0c\/cart \u8bf7\u6c42\u5b9e\u9645\u8c03\u7528\u7684\u662f \/clear API\u3002<\/p><\/blockquote>\n\n\n\n<p>\u4e0b\u9762\u6211\u4eec\u914d\u7f6e \/cart \u7684\u8bf7\u6c42\u91cd\u5199\u4e3a \/clear\u3002<\/p>\n\n\n\n<p><strong>1.&nbsp;<\/strong>\u4f7f\u7528 VirtualService \u914d\u7f6e \/cart \u8bf7\u6c42\u5728\u8fdb\u884c\u5b9e\u9645\u8c03\u7528\u524d\uff0c\u5c06 URI \u91cd\u5199\u4e3a \/clear\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: networking.istio.io\/v1alpha3<\/code><code>kind: VirtualService<\/code><code>metadata:<\/code><code>  name: apis-vs<\/code><code>  namespace: default<\/code><code>spec:<\/code><code>  hosts:<\/code><code>    - 121.4.8.11<\/code><code>  gateways:<\/code><code>    - default\/apis-gw<\/code><code>  http:<\/code><code>    - match:<\/code><code>        - uri:<\/code><code>            exact: \/cart<\/code><code>      route:<\/code><code>        - destination:<\/code><code>            host: cart.base.svc.cluster.local<\/code><code>      rewrite:<\/code><code>        uri: \/clear<\/code><\/code><\/pre>\n\n\n\n<p><strong>2.&nbsp;<\/strong>\u53d1\u8d77 \/cart \u8bf7\u6c42\uff0c\u5ba2\u6237\u7aef\u4e0d\u611f\u77e5\u91cd\u5199\u64cd\u4f5c\uff0c\u7531\u670d\u52a1\u7aef\u6267\u884c\uff0c\u5b9e\u9645\u8c03\u7528\u7684\u662f \/clear API\uff0ccart \u670d\u52a1\u7684 \/clear API \u6210\u529f\u8fd4\u56de\u8c03\u7528\u6e05\u7a7a\u8d2d\u7269\u8f66\u6210\u529f\u7684\u4fe1\u606f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ curl http:\/\/$INGRESS_HOST\/cart -H 'UserID: 1'<\/code><code>{\"Success\":\"true\"}<\/code><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h2-3-4-\"><a><\/a>3.4 \u9ad8\u53ef\u7528\u8c03\u5ea6<\/h2>\n\n\n\n<p>\u968f\u7740\u4e1a\u52a1\u89c4\u6a21\u7684\u589e\u52a0\uff0c\u6216\u5bf9\u8de8\u53ef\u7528\u533a\/\u5730\u57df\u5bb9\u707e\u3001\u6570\u636e\u5408\u89c4\u6027\u3001\u4e1a\u52a1\u4e4b\u95f4\u9694\u79bb\u8981\u6c42\u7684\u63d0\u5347\uff0c\u4e1a\u52a1\u4f1a\u8003\u8651\u4e0e\u5b9e\u65bd\u90e8\u7f72\u591a\u4e2a Kubernetes \u96c6\u7fa4\uff0c\u628a\u540c\u4e00\u4e2a\u670d\u52a1\u90e8\u7f72\u5728\u8de8\u53ef\u7528\u533a\/\u5730\u57df\u7684\u591a\u4e2a\u96c6\u7fa4\uff0c\u505a\u9ad8\u53ef\u7528\u8c03\u5ea6\u3002\u4e3b\u8981\u6709\u4e24\u79cd\u8bc9\u6c42\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li><strong>\u5730\u57df&amp;\u9519\u8bef\u611f\u77e5\u81ea\u52a8 failover<\/strong>\uff1a\u6839\u636e\u670d\u52a1\u7684\u5730\u57df\u4fe1\u606f\u4e0e endpoint \u5065\u5eb7\u4fe1\u606f\u786e\u5b9a\u6d41\u91cf\u7684\u53ef\u7528\u533a\/\u5730\u57df\u5206\u53d1\u7b56\u7565\uff0c\u5f53 endpoint \u5065\u5eb7\u5ea6\u9ad8\u4e8e\u9608\u503c\u65f6\uff0c\u6d41\u91cf 100% \u5728\u672c\u5730\u8def\u7531\uff0c\u4f4e\u4e8e\u9608\u503c\u65f6\uff0c\u89c6 endpoint \u5065\u5eb7\u5ea6\u81ea\u52a8 failover \u4e00\u5b9a\u6bd4\u4f8b\u6d41\u91cf\u81f3\u5176\u4ed6\u53ef\u7528\u533a\/\u5730\u57df\uff0c\u76f4\u81f3 endpoint \u5168\u90e8\u4e0d\u5065\u5eb7\u65f6 100% \u6d41\u91cf\u81ea\u52a8 failover \u81f3\u5176\u4ed6\u53ef\u7528\u533a\/\u5730\u57df\u3002endpoint \u5065\u5eb7\u4fe1\u606f\u611f\u77e5\u4f9d\u8d56\u4e8e\u5065\u5eb7\u68c0\u67e5\u7684\u80fd\u529b\u3002<\/li><li><strong>\u5730\u57df\u611f\u77e5\u6d41\u91cf\u5206\u53d1<\/strong>\uff1a\u4e0d\u6309\u7167\u5730\u57df\u4e0e\u9519\u8bef\u4fe1\u606f\u81ea\u52a8 failover \u6d41\u91cf\uff0c\u7ba1\u7406\u5458\u81ea\u5b9a\u4e49\u914d\u7f6e\u8de8\u53ef\u7528\u533a\/\u5730\u57df\u591a\u96c6\u7fa4\u6d41\u91cf\u5206\u53d1\u7b56\u7565\uff0c\u4f8b\u5982\u914d\u7f6e\u6765\u81ea\u4e0a\u6d77\u4e00\u533a\u7684\u6d41\u91cf\u5728\u4e0a\u6d77\u4e00\u533a\u548c\u4e0a\u6d77\u4e8c\u533a\u6309\u7167 80% \u548c 20% \u7684\u6bd4\u4f8b\u5206\u53d1\u3002\u65e0\u987b\u611f\u77e5 endpoint \u5065\u5eb7\uff0c\u4e0d\u4f9d\u8d56\u5065\u5eb7\u68c0\u67e5\u7684\u80fd\u529b\u3002<\/li><\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h3-3-4-1-amp-failover\"><a><\/a>3.4.1 \u5730\u57df&amp;\u9519\u8bef\u611f\u77e5\u81ea\u52a8 failover<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u968f\u7740 TCM demo \u7f51\u7ad9\u540e\u53f0\u89c4\u6a21\u589e\u52a0\uff0c\u5bf9\u540e\u53f0\u670d\u52a1\u5bb9\u707e\u7684\u8bc9\u6c42\u4e5f\u63d0\u4e0a\u65e5\u7a0b\uff0c\u5e0c\u671b\u5b9e\u73b0 user \u670d\u52a1\u7684\u8de8\u96c6\u7fa4\uff08\u672c\u6b21\u4ee5\u96c6\u7fa4\u8de8\u53ef\u7528\u533a\u4e3a\u4f8b\uff09\u5bb9\u707e\uff0c\u5728\u4e0a\u6d77\u4e8c\u533a\u65b0\u589e\u4e00\u4e2a\u4e1a\u52a1\u96c6\u7fa4\u90e8\u7f72 user \u5907\u4efd\u670d\u52a1\uff0c\u6d41\u91cf\u4ecd\u7136\u662f\u4ece\u4e0a\u6d77\u4e00\u533a\u7684 ingress gateway \u8bbf\u95ee user\u3002\u5e0c\u671b\u5728\u4e0a\u6d77\u4e00\u533a user \u670d\u52a1 endpoints \u90fd\u5065\u5eb7\u65f6\uff0c\u5c31\u8fd1\u8bbf\u95ee\u672c\u53ef\u7528\u533a\u7684 user\uff0c\u5f53\u4e0a\u6d77\u4e00\u533a user endpoints \u5065\u5eb7\u6bd4\u4f8b\u4e0b\u964d\u5230\u4e00\u5b9a\u7a0b\u5ea6\u65f6\uff08\u4f8b\u5982 71.4%\uff09\uff0c\u5f00\u59cb\u89c6\u5065\u5eb7\u7a0b\u5ea6\u8f6c\u79fb\u4e00\u5b9a\u6bd4\u4f8b\u7684\u6d41\u91cf\u5230\u4e0a\u6d77\u4e8c\u533a\u7684 user endpoints\uff0c\u76f4\u81f3\u4e0a\u6d77\u4e00\u533a user endpoints \u5065\u5eb7\u7a0b\u5ea6\u5b8c\u5168\u4e0b\u964d\u4e3a 0% \u65f6\u5c06\u6d41\u91cf\u5b8c\u5168\u5207\u5230\u4e0a\u6d77\u4e8c\u533a user \u5907\u4efd\u3002<\/p><\/blockquote>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1484\" height=\"1118\" src=\"https:\/\/rannix.cloud\/wp-content\/uploads\/2022\/08\/s1-n2-failover.png\" alt=\"\" class=\"wp-image-85\" title=\"s1-n2-failover.png\"\/><\/figure>\n\n\n\n<p><strong>\u73af\u5883\u51c6\u5907\uff1a<\/strong><\/p>\n\n\n\n<p><strong>1.&nbsp;<\/strong>\u6dfb\u52a0\u4e00\u4e2a\u4e0a\u6d77\u4e8c\u533a\u7684 TKE \u96c6\u7fa4\uff08\u5982\u4f7f\u7528 TCM \u4e00\u952e\u4f53\u9a8c\u529f\u80fd\u642d\u5efa\u73af\u5883\uff0c\u53ef\u8df3\u8fc7\uff0cTCM \u4e00\u952e\u4f53\u9a8c\u5df2\u7ecf\u51c6\u5907\u4e86\u7b2c\u4e8c\u4e2a\u53ef\u7528\u533a\u7684\u670d\u52a1\u53d1\u73b0\u96c6\u7fa4\uff09\uff0c\u5e76\u5728\u6b64\u96c6\u7fa4\u90e8\u7f72 user \u670d\u52a1\uff08replicas: 14\uff09\u4f5c\u4e3a\u4e0a\u6d77\u4e00\u533a user \u670d\u52a1\u7684\u5bb9\u707e\u5907\u4efd\u670d\u52a1\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: v1<\/code><code>kind: Namespace<\/code><code>metadata:<\/code><code>  name: base<\/code><code>spec:<\/code><code>  finalizers:<\/code><code>    - kubernetes<\/code><code>---<\/code><code>apiVersion: v1<\/code><code>kind: Service<\/code><code>metadata:<\/code><code>  name: user<\/code><code>  namespace: base<\/code><code>  labels:<\/code><code>    app: user<\/code><code>spec:<\/code><code>  ports:<\/code><code>    - port: 7000<\/code><code>      name: http<\/code><code>  selector:<\/code><code>    app: user<\/code><code>---<\/code><code>apiVersion: apps\/v1<\/code><code>kind: Deployment<\/code><code>metadata:<\/code><code>  name: user<\/code><code>  namespace: base<\/code><code>  labels:<\/code><code>    app: user<\/code><code>spec:<\/code><code>  replicas: 14<\/code><code>  selector:<\/code><code>    matchLabels:<\/code><code>      app: user<\/code><code>  template:<\/code><code>    metadata:<\/code><code>      labels:<\/code><code>        app: user<\/code><code>    spec:<\/code><code>      containers:<\/code><code>        - name: user<\/code><code>          image: ccr.ccs.tencentyun.com\/zhulei\/testuser:v1<\/code><code>          imagePullPolicy: Always<\/code><code>          env:<\/code><code>            - name: POD_NAME<\/code><code>              valueFrom:<\/code><code>                fieldRef:<\/code><code>                  fieldPath: metadata.name<\/code><code>            - name: REGION<\/code><code>              value: \"shanghai-zone2\"<\/code><code>          ports:<\/code><code>            - containerPort: 7000<\/code><\/code><\/pre>\n\n\n\n<p><strong>2.<\/strong>&nbsp;\u8c03\u6574\u539f\u6709\u4e0a\u6d77\u4e00\u533a\u96c6\u7fa4 user \u670d\u52a1\u7684 healthy \u548c unhealthy pods \u6570\u91cf\u5206\u522b\u4e3a 10 \u548c 4\u3002\u8c03\u6574\u5b8c\u6210\u540e\u4e00\u533a\u548c\u4e8c\u533a\u7684 user \u670d\u52a1 endpoints \u6570\u91cf\u60c5\u51b5\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ kubectl get deployment user user-unhealthy -n base<\/code><code>NAME             READY   UP-TO-DATE   AVAILABLE   AGE<\/code><code>user             10\/10   10           10          8d<\/code><code>user-unhealthy   4\/4     4            4           5d2h<\/code><\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ kubectl get deployment user -n base<\/code><code>NAME   READY   UP-TO-DATE   AVAILABLE   AGE<\/code><code>user   14\/14   14           14          5d2h<\/code><\/code><\/pre>\n\n\n\n<p>\u4e0b\u9762\u6211\u4eec\u51c6\u5907\u914d\u7f6e\u5f00\u542f\u4e0e\u6d4b\u8bd5 Istio Ingress Gateway \u7684\u5730\u57df\u611f\u77e5\u8d1f\u8f7d\u5747\u8861\u529f\u80fd\u3002<\/p>\n\n\n\n<p><strong>1.&nbsp;<\/strong>TCM \u7684\u5730\u57df\u611f\u77e5\u529f\u80fd\u9ed8\u8ba4\u5f00\u542f\uff0c\u6211\u4eec\u53ea\u9700\u8981\u914d\u7f6e user \u670d\u52a1\u7684 Outlier Detection\uff0c\u5730\u57df\u611f\u77e5\u8d1f\u8f7d\u5747\u8861\u5373\u53ef\u751f\u6548\u3002\u4e14\u9ed8\u8ba4\u5f53\u4e0a\u6d77\u4e00\u533a user endpoints \u5065\u5eb7\u6bd4\u4f8b\u4e0b\u964d\u81f3 10\/14 \uff0871.4%\uff09\u540e\uff0c\u4f1a\u5f00\u59cb\u6309\u6bd4\u4f8b\u8f6c\u79fb\u4e00\u533a\u7684\u6d41\u91cf\u5230\u4e8c\u533a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: networking.istio.io\/v1alpha3<\/code><code>kind: DestinationRule<\/code><code>metadata:<\/code><code>  name: user<\/code><code>  namespace: base<\/code><code>spec:<\/code><code>  host: user<\/code><code>  trafficPolicy:<\/code><code>    outlierDetection:<\/code><code>      consecutiveErrors: 3<\/code><code>      interval: 10000ms<\/code><code>      baseEjectionTime: 30000ms<\/code><code>      maxEjectionPercent: 100<\/code><code>      minHealthPercent: 0<\/code><code>  exportTo:<\/code><code>    - '*'<\/code><\/code><\/pre>\n\n\n\n<p><strong>2.&nbsp;<\/strong>\u5f53\u524d\u4ece Ingress Gateway\uff08\u4e0a\u6d77\u4e00\u533a\uff09\u8bbf\u95ee user \u670d\u52a1\u7684\u6d41\u91cf\uff0c\u5f53\u524d\u4e0a\u6d77\u4e00\u533a user \u670d\u52a1\u5065\u5eb7\u6bd4\u4f8b\u8fd8\u672a\u5c0f\u4e8e 10\/14 \u7684\u4e34\u754c\u503c\uff0c\u56e0\u6b64\u8bbf\u95ee user \u670d\u52a1\u7684\u6d41\u91cf\u5168\u90e8\u7531\u4e0a\u6d77\u4e00\u533a\u7684 user endpoints \u63d0\u4f9b\u3002\u53d1\u8d77\u4e00\u7ec4\u8bf7\u6c42\u9a8c\u8bc1\uff0c\u6240\u6709\u6d41\u91cf\u5747\u88ab\u8def\u7531\u5230\u4e86\u4e0a\u6d77\u4e00\u533a\u7684 endpoints\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ for((i=0;i&lt;10;i++)) do curl http:\/\/$INGRESS_HOST\/user | jq '.Info&#91;0].Region'; done<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone1\"<\/code><\/code><\/pre>\n\n\n\n<p><strong>3.&nbsp;<\/strong>\u8c03\u6574\u4e0a\u6d77\u4e00\u533a\u96c6\u7fa4\u5185 user \u670d\u52a1\u5065\u5eb7\u4e0e\u975e\u5065\u5eb7 endpoints \u7684\u6bd4\u4f8b\uff0c\u8c03\u6574\u5065\u5eb7 endpoints \u4e3a 5\uff0c\u4e0d\u5065\u5eb7endpoints \u4e3a 9\u3002\u6b64\u65f6\u5065\u5eb7\u4e0a\u6d77\u4e00\u533a user \u670d\u52a1\u7684\u5065\u5eb7\u6bd4\u4f8b 5\/14 \u5df2\u7ecf\u5c0f\u4e8e 10\/14\uff0c\u5e94\u5f53\u6709\u90e8\u5206\u6d41\u91cf\u88ab\u5207\u81f3\u4e0a\u6d77\u4e8c\u533a\uff0c\u53d1\u8d77\u4e00\u7ec4\u8bf7\u6c42\u9a8c\u8bc1\uff0c\/user \u6d41\u91cf\u90e8\u5206\u88ab\u8def\u7531\u81f3\u4e0a\u6d77\u4e8c\u533a\uff0c\u8def\u7531\u81f3\u4e0a\u6d77\u4e00\u533a\/\u4e8c\u533a\u7684\u6bd4\u4f8b\u5927\u81f4\u5747\u8861\u4e3a 1:1\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ for((i=0;i&lt;10;i++)) do curl http:\/\/$INGRESS_HOST\/user | jq '.Info&#91;0].Region'; done<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone2\"<\/code><\/code><\/pre>\n\n\n\n<p><strong>4.&nbsp;<\/strong>\u7ee7\u7eed\u8c03\u6574\u4e0a\u6d77\u4e00\u533a\u96c6\u7fa4\u5185 user \u670d\u52a1\u5065\u5eb7\u4e0e\u975e\u5065\u5eb7 endpoints \u7684\u6bd4\u4f8b\uff0c\u5065\u5eb7 endpoints \u4e3a 0\uff0c\u4e0d\u5065\u5eb7 endpoints \u4e3a 14\uff0c\u6b64\u65f6\u4e0a\u6d77\u4e00\u533a user \u670d\u52a1\u5065\u5eb7\u6bd4\u4f8b\u4e3a 0%\uff0c\u4e0d\u5177\u5907\u63d0\u4f9b\u540e\u7aef\u670d\u52a1\u7684\u80fd\u529b\uff0c\u5e94\u5f53\u5c06\u6240\u6709 \/user \u8bf7\u6c42\u8def\u7531\u5230\u4e0a\u6d77\u4e8c\u533a\u3002\u53d1\u8d77\u4e00\u7ec4\u8bf7\u6c42\u9a8c\u8bc1\uff0c\u6240\u6709\u6d41\u91cf\u5747\u88ab\u8def\u7531\u81f3\u4e0a\u6d77\u4e8c\u533a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ for((i=0;i&lt;10;i++)) do curl http:\/\/$INGRESS_HOST\/user | jq '.Info&#91;0].Region'; done<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><\/code><\/pre>\n\n\n\n<p>Istio \u9ed8\u8ba4\u7b56\u7565\u4e3a\u5f53\u6d41\u91cf\u9700\u8981 failover \u65f6\uff0c\u4f1a\u5728\u4e0b\u4e00\u540c\u7b49\u5730\u57df\u4f18\u5148\u7ea7\u7684<strong>\u6240\u6709<\/strong>\u5730\u57df\u5185\u5168\u5c40\u8d1f\u8f7d\u5747\u8861\uff0c\u540c\u4e00\u4e2a\u670d\u52a1\u82e5\u6709\u8d85\u8fc7 2 \u4e2a\u5730\u57df\u7684\u90e8\u7f72\uff0c\u5219\u9700\u8003\u8651\u914d\u7f6e failover \u4f18\u5148\u7ea7\uff0c\u4f8b\u5982 user \u670d\u52a1\u5728\u5e7f\u5dde\u3001\u4e0a\u6d77\u3001\u5317\u4eac\u5747\u6709\u90e8\u7f72\u65f6\uff0c\u9700\u8981\u914d\u7f6e\u5f53\u5e7f\u5dde\u7684 endpoints \u5065\u5eb7\u6bd4\u4f8b\u4e0b\u964d\u5230\u9608\u503c\u4e4b\u4e0b\u65f6\uff0c\u6d41\u91cf failover \u7684\u5730\u57df\u662f\u6700\u8fd1\u7684\u4e0a\u6d77\u800c\u4e0d\u662f\u66f4\u8fdc\u7684\u5317\u4eac\u6216\u5728\u4e0a\u6d77\u548c\u5317\u4eac\u5168\u5c40\u8d1f\u8f7d\u5747\u8861\uff0c\u4f7f\u7528 localityLbSetting \u7684 failover \u53c2\u6570\u5373\u53ef\u914d\u7f6e\u3002\u5f53 user \u670d\u52a1\u5728\u5e7f\u5dde\u3001\u4e0a\u6d77\u3001\u5317\u4eac\u5747\u6709\u90e8\u7f72\u65f6\u6211\u4eec\u53ef\u4ee5\u5982\u4e0b\u914d\u7f6e\u5730\u57df\u95f4 failover \u7b56\u7565\uff0c\u914d\u7f6e\u65b9\u5f0f\u4e0e distribute \u7b56\u7565\u76f8\u540c\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>failover:<\/code><code>   - from: gz<\/code><code>     to: sh<\/code><code>   - from: sh<\/code><code>     to: gz<\/code><code>   - from: bj<\/code><code>     to: sh<\/code><\/code><\/pre>\n\n\n\n<div class=\"wp-block-group has-cyan-bluish-gray-color has-text-color is-layout-flow wp-block-group-is-layout-flow\">\n<p class=\"has-small-font-size\">TL;DR. \u4ee5\u4e0b\u5185\u5bb9\u662f\u5730\u57df\u611f\u77e5\u8d1f\u8f7d\u5747\u8861\u83b7\u53d6 endpoints \u5065\u5eb7\u7a0b\u5ea6\u3001\u5730\u57df\u4fe1\u606f\u3001\u786e\u5b9a\u6d41\u91cf\u8f6c\u79fb\u6bd4\u4f8b\u7684\u80cc\u666f\u77e5\u8bc6\u8865\u5145\u3002<\/p>\n\n\n\n<p class=\"has-small-font-size\">\u5b9e\u73b0\u8de8\u53ef\u7528\u533a\/\u5730\u57df\u591a\u96c6\u7fa4\u5730\u57df\u611f\u77e5\u8d1f\u8f7d\u5747\u8861\uff0c\u89c6\u670d\u52a1 endpoints \u5730\u57df\u4fe1\u606f\u53ca\u5065\u5eb7\u7a0b\u5ea6\u6309\u6bd4\u4f8b failover \u6d41\u91cf\uff0c\u9700\u8981\u5177\u5907\u4ee5\u4e0b\u80fd\u529b\uff1a<\/p>\n\n\n\n<p class=\"has-small-font-size\"><strong>1. \u8054\u901a\u591a\u96c6\u7fa4\u7f51\u7edc\u5e76\u53d1\u73b0\u6240\u6709\u96c6\u7fa4\u7684\u670d\u52a1\uff1a<\/strong><\/p>\n\n\n\n<p class=\"has-small-font-size\">\u8de8\u96c6\u7fa4\u7f51\u7edc\u8fde\u901a\u540e\uff0cIstiod \u53ef\u4ee5\u4ece\u591a\u4e2a\u96c6\u7fa4\u7684 API Server \u4e2d\u83b7\u53d6\u670d\u52a1\u4e0e endpoint \u4fe1\u606f\uff0c\u5e76\u63a8\u9001\u7ed9\u6570\u636e\u9762\u4ee3\u7406 Envoy Pod\u3002<\/p>\n\n\n\n<p class=\"has-small-font-size\"><strong>2. \u83b7\u53d6\u670d\u52a1\u7684\u5730\u7406\u4f4d\u7f6e\u4fe1\u606f\uff1a<\/strong><\/p>\n\n\n\n<p class=\"has-small-font-size\">\u5b9e\u73b0\u5c31\u8fd1\u8bbf\u95ee\u4e0e\u5bb9\u707e\uff0c\u9700\u8981\u670d\u52a1\u7684\u5730\u7406\u4f4d\u7f6e\u4fe1\u606f\uff0c\u5728\u670d\u52a1\u7f51\u683c\u4e2d\uff0c\u5730\u7406\u4f4d\u7f6e\u7531\u6709\u5982\u4e0b\u4e09\u4e2a\u5c42\u7ea7\u7684\u4fe1\u606f\uff1aregion\uff0czone\uff0csubzone\u3002\u5176\u4e2d region \u548c zone \u7684\u4fe1\u606f\u5206\u522b\u6765\u81ea\u96c6\u7fa4\u8282\u70b9\u7684&nbsp;<code>topology.kubernetes.io\/region<\/code>&nbsp;\u6807\u7b7e\u548c&nbsp;<code>topology.kubernetes.io\/region<\/code>&nbsp;\u6807\u7b7e\u3002\u8fd9\u4e24\u4e2a\u6807\u7b7e\u5728 TKE \u96c6\u7fa4\u4e2d\u5df2\u7ecf\u63d0\u4f9b&nbsp;<a href=\"https:\/\/istio.io\/v1.8\/docs\/ops\/configuration\/traffic-management\/locality-load-balancing\/\"><\/a><a href=\"https:\/\/istio.io\/v1.8\/docs\/ops\/configuration\/traffic-management\/locality-load-balancing\/\">10<\/a>\uff0c\u4f8b\u5982\u4e0a\u6d77\u4e00\u533a\u8282\u70b9\u7684\u6807\u7b7e\u4e3a\uff1a<code>topology.kubernetes.io\/region: sh<\/code>\uff0c<code>topology.kubernetes.io\/zone: \"2000400001\"<\/code>\uff1b\u4e0a\u6d77\u4e8c\u533a\u8282\u70b9\u7684\u6807\u7b7e\u4e3a\uff1a<code>topology.kubernetes.io\/region: sh<\/code>\uff0c<code>topology.kubernetes.io\/zone: \"200002\"<\/code>\u3002<\/p>\n\n\n\n<p class=\"has-small-font-size\">Kubernetes \u4e0d\u5b58\u5728 subzone \u7684\u6982\u5ff5\uff0cIstio \u5f15\u5165\u4e86&nbsp;<code>topology.istio.io\/subzone<\/code>&nbsp;\u7684\u6807\u7b7e\u5b9a\u4e49 subzone\uff0c\u53ef\u6839\u636e\u9700\u8981\u914d\u7f6e\u3002<\/p>\n\n\n\n<p class=\"has-small-font-size\">\u5728 Istio \u9ed8\u8ba4\u4f7f\u7528\u7684\u5730\u57df\u4f18\u5148\u8d1f\u8f7d\u5747\u8861\u7b56\u7565\u4e2d\uff0c\u4f18\u5148\u7ea7\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p class=\"has-small-font-size\">&#8211; Priority 0 \u6700\u9ad8\u4f18\u5148\u7ea7\uff0c\u540c\u5730\u57df\u540c\u53ef\u7528\u533a\uff1b<\/p>\n\n\n\n<p class=\"has-small-font-size\">&#8211; Priority 1\uff0c\u540c\u5730\u57df\u4e0d\u540c\u53ef\u7528\u533a\uff1b<\/p>\n\n\n\n<p class=\"has-small-font-size\">&#8211; Priority 2 \u6700\u4f4e\u4f18\u5148\u7ea7\uff0c\u4e0d\u540c\u5730\u57df\u3002<\/p>\n\n\n\n<p class=\"has-small-font-size\"><strong>3. \u83b7\u53d6\u670d\u52a1 endpoints \u7684\u5065\u5eb7\u4fe1\u606f\uff1a<\/strong><\/p>\n\n\n\n<p class=\"has-small-font-size\">endpoints \u5065\u5eb7\u4fe1\u606f\u83b7\u53d6\u4f9d\u8d56\u5f00\u542f Istio \u7684\u5065\u5eb7\u68c0\u67e5\uff1a Outlier Detection\u3002\u5730\u57df&amp;\u9519\u8bef\u81ea\u52a8 failover \u529f\u80fd\u4f9d\u8d56\u5065\u5eb7\u68c0\u67e5\uff0c\u672a\u5f00\u542f\u65f6\uff0c\u6570\u636e\u9762\u65e0\u6cd5\u5f97\u77e5\u670d\u52a1 endpoints \u7684\u5065\u5eb7\u72b6\u51b5\uff0c\u9ed8\u8ba4\u6309\u7167\u5168\u5c40\u7684\u65b9\u5f0f\u8fdb\u884c\u6d41\u91cf\u8d1f\u8f7d\u5747\u8861\u3002\u5730\u57df\u611f\u77e5\u6d41\u91cf\u5206\u53d1 distribute \u4e0d\u4f9d\u8d56\u5f00\u542f\u5065\u5eb7\u68c0\u67e5\u3002<\/p>\n\n\n\n<p class=\"has-small-font-size\"><strong>4. \u5224\u5b9a\u670d\u52a1\u5065\u5eb7\u72b6\u6001&amp;\u786e\u5b9a\u6d41\u91cf\u8f6c\u79fb\u6bd4\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<p class=\"has-small-font-size\">\u4e00\u4e2a\u670d\u52a1\u4f1a\u90e8\u7f72\u591a\u4e2a\u526f\u672c\uff0c\u670d\u52a1\u7684\u5065\u5eb7\u72b6\u6001\u4e0d\u662f\u7edd\u5bf9\u7684 0 \u548c 1 \u7684\u72b6\u6001\uff0c\u6d41\u91cf\u7684\u8f6c\u79fb\u662f\u4e00\u4e2a\u9010\u6b65\u8f6c\u79fb\u7684\u8fc7\u7a0b\uff0c\u4e0d\u5065\u5eb7 endpoints \u8d85\u8fc7\u4e00\u5b9a\u6bd4\u4f8b\u65f6\uff0c\u518d\u5f00\u59cb\u6309\u6bd4\u4f8b\u9010\u6b65\u8fdb\u884c\u6d41\u91cf\u8f6c\u79fb\u3002Istio \u7684\u5730\u57df\u8d1f\u8f7d\u5747\u8861\u9ed8\u8ba4\u4f7f\u7528\u5730\u57df\u4f18\u5148\u7684\u7b56\u7565\uff0c\u5373\u63a7\u5236\u9762\u544a\u8bc9\u6570\u636e\u9762\u5728\u5065\u5eb7\u72b6\u6001\u4e0b\uff0c\u4f18\u5148\u8003\u8651\u5c06\u8bf7\u6c42\u53d1\u9001\u5230\u5730\u7406\u4f4d\u7f6e\u6700\u8fd1\u7684\u5b9e\u4f8b\uff0c\u5730\u7406\u4f18\u5148\u7ea7\u6700\u9ad8\u53ef\u7528\u533a\/\u5730\u57df endpoints \u5065\u5eb7\u5ea6 100% \u65f6\uff0c\u6240\u6709\u7684\u8bf7\u6c42\u90fd\u4f1a\u8def\u7531\u5230\u8fd9\u4e2a\u5730\u57df\uff0c\u4e0d\u4f1a\u505a\u6d41\u91cf\u8f6c\u79fb\uff0cendpoints \u4e0d\u5065\u5eb7\u6bd4\u4f8b\u8d85\u8fc7\u67d0\u9608\u503c\uff0c\u6d41\u91cf\u5c06\u5f00\u59cb\u6309\u6bd4\u4f8b\u9010\u6b65\u8f6c\u79fb\u3002<\/p>\n\n\n\n<p class=\"has-small-font-size\">\u8fd9\u4e2a\u9608\u503c\u7531 envoy \u7684 overprovisioning factor \u63a7\u5236\uff0c\u9ed8\u8ba4\u4e3a 1.4\uff0c\u6839\u636e\u8be5 factor \u53ca\u670d\u52a1 endpints \u5065\u5eb7\u6bd4\u4f8b\u53ef\u786e\u5b9a\u4e0d\u540c\u5730\u7406 Priority Level \u7684\u6d41\u91cf\u6bd4\u4f8b\u3002\u4f8b\u5982\uff0c\u5047\u8bbe\u76ee\u524d\u67d0\u670d\u52a1\u5728\u5e7f\u5dde\u548c\u4e0a\u6d77\u4e24\u4e2a\u5730\u57df\u5747\u6709 endpoints\uff0c\u6d41\u91cf\u5165\u53e3 Ingress Gateway \u90e8\u7f72\u5728\u5e7f\u5dde\u3002\u901a\u8fc7\u5e7f\u5dde Ingress Gateway \u8bbf\u95ee\u8be5\u670d\u52a1\u7684\u6d41\u91cf\uff0c\u6309\u7167\u4f18\u5148\u7ea7\u5e7f\u5dde\u7684\u670d\u52a1\u4e3a P0 \u4f18\u5148\u7ea7\uff0c\u4e0a\u6d77\u7684\u670d\u52a1\u4e3a P1 \u4f18\u5148\u7ea7\u3002\u5047\u8bbe\u4e0a\u6d77\u4f5c\u4e3a\u5bb9\u707e\u7684\u5730\u57df\uff0c\uff0cendpoints \u5065\u5eb7\u6bd4\u4f8b\u4e00\u76f4\u4e3a 100%\uff0c\u5047\u8bbe\u5e7f\u5dde\u4e0a\u6d77\u4e24\u4e2a\u5730\u57df\u7684\u6743\u91cd\u76f8\u7b49\uff0coverprovisioning factor \u4e3a\u9ed8\u8ba4\u503c 1.4\u3002\u4e24\u4e2a\u5730\u57df\u6d41\u91cf\u8d1f\u8f7d\u6bd4\u4f8b\u8ba1\u7b97\u8fc7\u7a0b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul class=\"has-small-font-size wp-block-list\"><li><strong>\u5e7f\u5dde\u670d\u52a1 endpoints \u5065\u5eb7\u6bd4\u4f8b<\/strong>\uff1aP0_health = \u5e7f\u5dde\u670d\u52a1\u5065\u5eb7 endpoints \u6570\u91cf \/ \u5e7f\u5dde\u670d\u52a1 endpoints \u603b\u6570\uff1b<\/li><li><strong>\u5e7f\u5dde\u670d\u52a1\u6d41\u91cf\u8d1f\u8f7d\u6bd4\u4f8b<\/strong>\uff1aP0_traffic = min(1, P0_health * 1.4)\uff1b<\/li><li><strong>\u4e0a\u6d77\u670d\u52a1\u6d41\u91cf\u8d1f\u8f7d\u6bd4\u4f8b<\/strong>\uff1aP1_traffic = 1 &#8211; P0_traffic = max(0, 1 &#8211; P0_health * 1.4)\u3002<\/li><\/ul>\n\n\n\n<p class=\"has-small-font-size\">\u6309\u7167\u8be5\u8ba1\u7b97\u89c4\u5219\uff0coverprovisioning factor \u4e3a 1.4 \u65f6\uff1a<\/p>\n\n\n\n<ul class=\"has-small-font-size wp-block-list\"><li>\u5e7f\u5dde\u670d\u52a1 endpoints \u5065\u5eb7\u6bd4\u4f8b P0_health \u4f4e\u4e8e 71.4% \u65f6\uff0c\u8be5\u5730\u57df\u8bbf\u95ee\u8be5\u670d\u52a1\u7684\u6d41\u91cf\u624d\u4f1a\u5f00\u59cb\u5207\u6362\u81f3\u4e0a\u6d77\u5730\u57df\uff1b<\/li><li>\u5f53\u5e7f\u5dde\u5730\u57df\u7684 endpoints \u5065\u5eb7\u6bd4\u4f8b\u4e3a 50% \u65f6\uff0c\u4f1a\u6709 1 &#8211; 50% * 1.4 = 30% \u7684\u6d41\u91cf\u8f6c\u79fb\u5230\u4e0a\u6d77\u5730\u57df\u7684\u670d\u52a1\uff1b<\/li><li>\u5f53\u5e7f\u5dde\u5730\u57df endpoints \u5b8c\u5168\u4e0d\u53ef\u7528 P0_health = 0% \u65f6\uff0c\u6d41\u91cf\u624d\u4f1a\u88ab\u5b8c\u5168\u5207\u6362\u5230\u4e0a\u6d77\u5730\u57df\u3002<\/li><\/ul>\n\n\n\n<p class=\"has-small-font-size\">PX_traffic = min(100, PX_health * 1.4 * 100) \u53cd\u6620\u67d0\u5730\u57df\u67d0\u670d\u52a1\u5f53\u524d\u7684\u6d41\u91cf\u627f\u8f7d\u80fd\u529b\uff0cEnvoy \u793e\u533a\u79f0\u4e3a\u5065\u5eb7\u8bc4\u5206\u3002\u5f53\u6240\u6709\u5730\u57df\u7684\u5065\u5eb7\u8bc4\u5206\u603b\u548c\u4f4e\u4e8e 100 \u65f6\uff0cEnvoy \u5219\u8ba4\u4e3a\u5f53\u524d\u5065\u5eb7\u72b6\u6001\u6ca1\u6709\u5b8c\u5168\u5904\u7406\u8bf7\u6c42\u7684\u7684\u80fd\u529b\uff0c\u6b64\u65f6 Envoy \u4f1a\u6839\u636e\u5065\u5eb7\u8bc4\u5206\u7684\u6bd4\u4f8b\u5206\u914d\u8bf7\u6c42\u3002\u4f8b\u5982\u5e7f\u5dde\u548c\u4e0a\u6d77\u7684\u5065\u5eb7\u8bc4\u5206\u5206\u522b\u4e3a 20 \u548c 30 \u65f6\uff0c\u5206\u522b\u4f1a\u627f\u62c5 40% \u548c 60% \u7684\u8d1f\u8f7d&nbsp;<a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/load_balancing\/priority\"><\/a><a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/load_balancing\/priority\">11<\/a>\u3002<\/p>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h3-3-4-2-\"><a><\/a>3.4.2 \u5730\u57df\u611f\u77e5\u6d41\u91cf\u5206\u53d1<\/h3>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>\u4e1a\u52a1\u4e0d\u5e0c\u671b\u6d41\u91cf\u6839\u636e\u5730\u57df\u548c\u5065\u5eb7\u4fe1\u606f\u81ea\u52a8 failover\uff0c\u800c\u662f\u81ea\u5b9a\u4e49\u6d41\u91cf\u5206\u53d1\u7b56\u7565\uff0c\u6765\u81ea Istio Ingress Gateway\uff08\u4e0a\u6d77\u4e00\u533a\uff09\u7684 \/user \u8bf7\u6c42\u5728\u4e00\u533a\u548c\u4e8c\u533a\u6309\u7167 1:1 \u7684\u6bd4\u4f8b\u5747\u8861\u5206\u53d1\uff0c\u800c\u4e0d\u662f\u5e94\u7528 Istio \u9ed8\u8ba4\u7684\u81ea\u52a8 failover \u7b56\u7565\uff1a100% \u5065\u5eb7\u65f6\uff0c\u6765\u81ea\u4e0a\u6d77\u4e00\u533a\u7684\u8bf7\u6c42 100% \u8d1f\u8f7d\u5747\u8861\u81f3\u4e0a\u6d77\u4e00\u533a user endpoints\u3002<\/p><\/blockquote>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1484\" height=\"1118\" src=\"https:\/\/rannix.cloud\/wp-content\/uploads\/2022\/08\/s1-n2-distribute.png\" alt=\"\" class=\"wp-image-86\" title=\"s1-n2-distribute.png\"\/><\/figure>\n\n\n\n<p>\u53ef\u901a\u8fc7 meshconfig\uff08\u914d\u7f6e\u7f51\u683c\u5168\u5c40\uff09\u6216 DestinationRule\uff08\u914d\u7f6e\u5355\u4e2a\u670d\u52a1\uff09\u7684 distribute \u53c2\u6570\u6765\u914d\u7f6e\u81ea\u5b9a\u4e49\u5730\u57df\u611f\u77e5\u6d41\u91cf\u5206\u53d1\u7b56\u7565\u3002<\/p>\n\n\n\n<p><strong>1.&nbsp;<\/strong>\u6062\u590d\u4e0a\u6d77\u4e00\u533a\u548c\u4e8c\u533a user \u670d\u52a1 \u5065\u5eb7\/\u4e0d\u5065\u5eb7 endpoints \u6570\u91cf\u81f3\u6700\u521d\u72b6\u6001\uff0c\u4e00\u533a\u4e00\u5171 14 \u4e2aendpoints \u5168\u90e8\u5065\u5eb7\uff0c\u4e8c\u533a\u4e00\u5171 14 \u4e2aendpoints \u5168\u90e8\u5065\u5eb7\u3002\u6309\u7167 Istio Ingress Gateway \u9ed8\u8ba4\u7684\u5730\u57df\u611f\u77e5\u7b56\u7565\uff0c\u4ece Ingress Gateway\uff08\u4e0a\u6d77\u4e00\u533a\uff09\u8bbf\u95ee \/user \u7684\u6d41\u91cf\u4f1a\u5168\u90e8\u8def\u7531\u81f3\u4e0a\u6d77\u4e00\u533a\u7684 endpoints\u3002<\/p>\n\n\n\n<p><strong>2.&nbsp;<\/strong>\u914d\u7f6e user \u670d\u52a1\u7684 DestinationRule\uff0c\u81ea\u5b9a\u4e49\u6d41\u91cf\u8c03\u5ea6\u89c4\u5219\uff0c\u6765\u81ea\u4e0a\u6d77\u4e00\u533a\u7684\u6d41\u91cf\uff0c\u5747\u5300\u8def\u7531\u81f3\u4e0a\u6d77\u4e00\u533a\u548c\u4e8c\u533a\u7684 endpoints\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>apiVersion: networking.istio.io\/v1alpha3<\/code><code>kind: DestinationRule<\/code><code>metadata:<\/code><code>  name: user<\/code><code>  namespace: base<\/code><code>spec:<\/code><code>  host: user<\/code><code>  trafficPolicy:<\/code><code>    loadBalancer:<\/code><code>      localityLbSetting:<\/code><code>        distribute:<\/code><code>          - from: sh\/2000400001\/*<\/code><code>            to:<\/code><code>              sh\/2000400001\/*: 50<\/code><code>              sh\/200002\/*: 50<\/code><code>        enabled: true<\/code><code>    outlierDetection:<\/code><code>      consecutiveErrors: 3<\/code><code>      interval: 10000ms<\/code><code>      baseEjectionTime: 30000ms<\/code><code>      maxEjectionPercent: 100<\/code><code>      minHealthPercent: 0<\/code><code>  exportTo:<\/code><code>    - '*'<\/code><\/code><\/pre>\n\n\n\n<p><strong>3.&nbsp;<\/strong>\u53d1\u8d77\u4e00\u7ec4 \/user \u8bf7\u6c42\u9a8c\u8bc1\uff0c\u6d41\u91cf\u88ab\u6bd4\u8f83\u5747\u8861\u7684\u8def\u7531\u5230\u4e86\u4e00\u533a\u548c\u4e8c\u533a\u7684 endpoints\uff0c\u800c\u4e0d\u662f Istio Ingress Gateway \u9ed8\u8ba4\u5730\u57df\/\u9519\u8bef\u611f\u77e5\u81ea\u52a8 failover\uff08100% \u6d41\u91cf\u8def\u7531\u5230\u4e0a\u6d77\u4e00\u533a\uff09\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>$ for((i=0;i&lt;10;i++)) do curl http:\/\/$INGRESS_HOST\/user | jq '.Info&#91;0].Region'; done<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone1\"<\/code><code>\"shanghai-zone2\"<\/code><code>\"shanghai-zone2\"<\/code><\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"h1-4-\"><a><\/a>4. \u7ed3\u8bed<\/h1>\n\n\n\n<p>\u672c\u6587\u4ecb\u7ecd\u4e86 Istio Ingress Gateway \u6d41\u91cf\u7ba1\u7406\u7684\u6280\u672f\u539f\u7406\u53ca\u6d41\u91cf\u7ba1\u7406\u6a21\u578b\u3002\u5e76\u4ece\u5165\u53e3\u6d41\u91cf\u5206\u53d1\u3001\u5bb9\u9519\u4e0e\u9ad8\u53ef\u7528\u8c03\u5ea6\u4e09\u4e2a\u65b9\u9762\u5b9e\u64cd\u6f14\u793a\u4e86\u5185\u5bb9\u8def\u7531\u3001\u6743\u91cd\u8def\u7531\u3001\u8d1f\u8f7d\u5747\u8861\u3001\u65ad\u8def\u5668\u3001\u5730\u57df&amp;\u9519\u8bef\u611f\u77e5\u81ea\u52a8 failover\u3001\u5730\u57df\u611f\u77e5\u6d41\u91cf\u5206\u53d1\u7b49\u529f\u80fd\u3002<\/p>\n\n\n\n<p>\u9664\u57fa\u672c\u7684\u5165\u53e3\u6d41\u91cf\u7ba1\u7406\u5916\uff0c\u5357\u5317\u6d41\u91cf\u7ba1\u7406\u8fd8\u6709\u5b89\u5168\u3001\u53ef\u89c2\u6d4b\u6027\u3001\u5f02\u6784\u670d\u52a1\u652f\u6301\u7b49\u573a\u666f\uff0c\u5c06\u5728\u540e\u7eed\u7cfb\u5217\u6587\u7ae0\u4e2d\u7ee7\u7eed\u8ba8\u8bba\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"h1-5-reference\"><a><\/a>5. Reference<\/h1>\n\n\n\n<p><a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/intro\">1<\/a>&nbsp;<a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/intro\">https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/intro<\/a><br><a href=\"https:\/\/kubernetes.io\/docs\/concepts\/extend-kubernetes\/api-extension\/custom-resources\/\">2<\/a>&nbsp;<a href=\"https:\/\/kubernetes.io\/docs\/concepts\/extend-kubernetes\/api-extension\/custom-resources\/\">https:\/\/kubernetes.io\/docs\/concepts\/extend-kubernetes\/api-extension\/custom-resources\/<\/a><br><a href=\"https:\/\/github.com\/Tencent-Cloud-Mesh\/mesh-demo\">3<\/a>&nbsp;<a href=\"https:\/\/github.com\/Tencent-Cloud-Mesh\/mesh-demo\">https:\/\/github.com\/Tencent-Cloud-Mesh\/mesh-demo<\/a><br><a href=\"https:\/\/istio.io\/latest\/docs\/setup\/getting-started\/#ip\">4<\/a>&nbsp;<a href=\"https:\/\/istio.io\/latest\/docs\/setup\/getting-started\/#ip\">https:\/\/istio.io\/latest\/docs\/setup\/getting-started\/#ip<\/a><br><a href=\"https:\/\/github.com\/Tencent-Cloud-Mesh\/mesh-demo\/blob\/master\/yamls\/step07-apps-product-v2.yaml\">5<\/a>&nbsp;<a href=\"https:\/\/github.com\/Tencent-Cloud-Mesh\/mesh-demo\/blob\/master\/yamls\/step07-apps-product-v2.yaml\">https:\/\/github.com\/Tencent-Cloud-Mesh\/mesh-demo\/blob\/master\/yamls\/step07-apps-product-v2.yaml<\/a><br><a href=\"https:\/\/cloud.tencent.com\/document\/product\/457\/45492\">6<\/a>&nbsp;<a href=\"https:\/\/cloud.tencent.com\/document\/product\/457\/45492\">https:\/\/cloud.tencent.com\/document\/product\/457\/45492<\/a><br><a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/circuit_breaking\">7<\/a>&nbsp;<a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/circuit_breaking\">https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/circuit_breaking<\/a><br><a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/outlier\">8<\/a>&nbsp;<a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/outlier\">https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/outlier<\/a><br><a href=\"https:\/\/developer.mozilla.org\/zh-CN\/docs\/Web\/HTTP\/Redirections\">9<\/a>&nbsp;<a href=\"https:\/\/developer.mozilla.org\/zh-CN\/docs\/Web\/HTTP\/Redirections\">https:\/\/developer.mozilla.org\/zh-CN\/docs\/Web\/HTTP\/Redirections<\/a><br><a href=\"https:\/\/istio.io\/v1.8\/docs\/ops\/configuration\/traffic-management\/locality-load-balancing\/\">10<\/a>&nbsp;<a href=\"https:\/\/istio.io\/v1.8\/docs\/ops\/configuration\/traffic-management\/locality-load-balancing\/\">https:\/\/istio.io\/v1.8\/docs\/ops\/configuration\/traffic-management\/locality-load-balancing\/<\/a><br><a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/load_balancing\/priority\">11<\/a>&nbsp;<a href=\"https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/load_balancing\/priority\">https:\/\/www.envoyproxy.io\/docs\/envoy\/latest\/intro\/arch_overview\/upstream\/load_balancing\/priority<\/a><br><a href=\"https:\/\/kubernetes.io\/docs\/concepts\/services-networking\/ingress-controllers\/\">12<\/a>&nbsp;<a href=\"https:\/\/kubernetes.io\/docs\/concepts\/services-networking\/ingress-controllers\/\">https:\/\/kubernetes.io\/docs\/concepts\/services-networking\/ingress-controllers\/<\/a><br><a href=\"https:\/\/istio.io\/latest\/docs\/ops\/deployment\/architecture\/#istiod\">13<\/a>&nbsp;<a href=\"https:\/\/istio.io\/latest\/docs\/ops\/deployment\/architecture\/#istiod\">https:\/\/istio.io\/latest\/docs\/ops\/deployment\/architecture\/#istiod<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction \u5728\u4e91\u539f\u751f\u5e94\u7528\u8d1f\u8f7d\u5747\u8861\u7cfb\u5217\u7b2c\u4e00\u7bc7\u6587\u7ae0\u300a\u4e91\u539f\u751f\u5e94\u7528\u8d1f\u8f7d\u5747\u8861\u9009\u578b\u6307\u5357\u300b\u4ecb\u7ecd\u4e86\u4e91\u539f\u751f\u5bb9 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/rannix.cloud\/index.php\/2022\/08\/22\/cloud_ingress2\/\" class=\"more-link\">Read more<span class=\"screen-reader-text\"> &#8220;\u4e91\u539f\u751f\u5e94\u7528\u8d1f\u8f7d\u5747\u8861\u7cfb\u52172: \u5165\u53e3\u6d41\u91cf\u5206\u53d1\u3001\u5bb9\u9519\u4e0e\u9ad8\u53ef\u7528\u8c03\u5ea6&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,1],"tags":[],"class_list":["post-74","post","type-post","status-publish","format-standard","hentry","category-service-mesh","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/rannix.cloud\/index.php\/wp-json\/wp\/v2\/posts\/74","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rannix.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rannix.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rannix.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rannix.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=74"}],"version-history":[{"count":6,"href":"https:\/\/rannix.cloud\/index.php\/wp-json\/wp\/v2\/posts\/74\/revisions"}],"predecessor-version":[{"id":87,"href":"https:\/\/rannix.cloud\/index.php\/wp-json\/wp\/v2\/posts\/74\/revisions\/87"}],"wp:attachment":[{"href":"https:\/\/rannix.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=74"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rannix.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=74"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rannix.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=74"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}