下发如下virtualservice策略,header中包含end-user:jason的请求发reviews的v2版本,其它的请求 50%发往v1,50%发往v2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
[root@k8s-master-v1-16 networking]# cat virtual-service-reviews-jason-weight-istio-bookinfo.yaml apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: reviews namespace: istio-bookinfo spec: hosts: - reviews http: - match: - headers: end-user: exact: jason route: - destination: host: reviews subset: v2 - route: - destination: host: reviews subset: v1 weight: 50 - destination: host: reviews subset: v3 weight: 50 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
$ istioctl proxy-config route productpage-v1-7f4cc988c6-qxqjs.istio-bookinfo --name 9080 -o json | grep -A 100 '"name": "reviews.istio-bookinfo.svc.cluster.local:9080",' "name": "reviews.istio-bookinfo.svc.cluster.local:9080", "domains": [ "reviews.istio-bookinfo.svc.cluster.local", "reviews.istio-bookinfo.svc.cluster.local:9080", "reviews", "reviews:9080", "reviews.istio-bookinfo.svc.cluster", "reviews.istio-bookinfo.svc.cluster:9080", "reviews.istio-bookinfo.svc", "reviews.istio-bookinfo.svc:9080", "reviews.istio-bookinfo", "reviews.istio-bookinfo:9080", "10.105.236.72", "10.105.236.72:9080" ], "routes": [ { "match": { "prefix": "/", "caseSensitive": true, "headers": [ { "name": "end-user", "exactMatch": "jason" } ] }, "route": { "cluster": "outbound|9080|v2|reviews.istio-bookinfo.svc.cluster.local", "timeout": "0s", "retryPolicy": { "retryOn": "connect-failure,refused-stream,unavailable,cancelled,retriable-status-codes", "numRetries": 2, "retryHostPredicate": [ { "name": "envoy.retry_host_predicates.previous_hosts" } ], "hostSelectionRetryMaxAttempts": "5", "retriableStatusCodes": [ 503 ] }, "maxGrpcTimeout": "0s" }, "metadata": { "filterMetadata": { "istio": { "config": "/apis/networking.istio.io/v1alpha3/namespaces/istio-bookinfo/virtual-service/reviews" } } }, "decorator": { "operation": "reviews.istio-bookinfo.svc.cluster.local:9080/*" } }, { "match": { "prefix": "/" }, "route": { "weightedClusters": { "clusters": [ { "name": "outbound|9080|v1|reviews.istio-bookinfo.svc.cluster.local", "weight": 50 }, { "name": "outbound|9080|v3|reviews.istio-bookinfo.svc.cluster.local", "weight": 50 } ] }, "timeout": "0s", "retryPolicy": { "retryOn": "connect-failure,refused-stream,unavailable,cancelled,retriable-status-codes", "numRetries": 2, "retryHostPredicate": [ { "name": "envoy.retry_host_predicates.previous_hosts" } ], "hostSelectionRetryMaxAttempts": "5", "retriableStatusCodes": [ 503 ] }, "maxGrpcTimeout": "0s" }, "metadata": { "filterMetadata": { "istio": { "config": "/apis/networking.istio.io/v1alpha3/namespaces/istio-bookinfo/virtual-service/reviews" } } }, "decorator": { "operation": "reviews:9080/*" } } ], |
文章评论