Istio 流量管理:示例二

发布时间: 更新时间: 总字数:1205 阅读时间:3m 作者:IP:上海 网址

Istio的流量管理示例一:Istio IngressGateWay和金丝雀示例。

示例

site1 ...

创建资源

crate-resource ...
istion-info ...

示例

访问普通流量

v1 ...

金丝雀流量

canary-v11 ...
  • 批量打流
$ for i in {1..100}; do curl  -H "x-canary: true"  --resolve site.kb.cx:30999:127.0.0.1 http://site.kb.cx:30999;done
welcome to site v1.1
...

debug

header 验证

  • 启用 v11 istio-proxy debug 日志
kubectl exec -it site-v11-86b97859cf-2qsdd -c istio-proxy -- curl -XPOST -s -o /dev/null http://localhost:15000/logging?level=debug
  • 通过 istiogateway 重新调用 canary 接口
root@k8s-master:~# curl -vvv -H "Host: site.kb.cx" -H "x-canary: true"  --resolve site.kb.cx:30999:127.0.0.1 http://site.kb.cx:30999
* Added site.kb.cx:30999:127.0.0.1 to DNS cache
* Hostname site.kb.cx was found in DNS cache
*   Trying 127.0.0.1:30999...
* TCP_NODELAY set
* Connected to site.kb.cx (127.0.0.1) port 30999 (#0)
> GET / HTTP/1.1
> Host: site.kb.cx
> User-Agent: curl/7.68.0
> Accept: */*
> x-canary: true
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< date: Wed, 31 Aug 2022 13:12:39 GMT
< content-type: text/html
< accept-ranges: bytes
< last-modified: Wed, 31 Aug 2022 12:52:15 GMT
< etag: "630f597f-15"
< content-length: 21
< x-envoy-upstream-service-time: 8
< server: istio-envoy
< x-canary: true  # header.response.add.x-canary 参数
<
welcome to site v1.1
* Connection #0 to host site.kb.cx left intact
  • v11 istio-proxy container 日志
$ kubectl logs -f site-v11-86b97859cf-2qsdd -c istio-proxy
...
2022-08-31T13:12:39.807421Z	debug	envoy router	[C649][S12133591032602623479] router decoding headers:
':authority', 'site.kb.cx'
':path', '/'
':method', 'GET'
':scheme', 'http'
'accept', '*/*'
'x-canary', 'true'
'x-forwarded-for', '10.244.0.0'
'x-forwarded-proto', 'http'
'x-request-id', '8dd6b72f-8c57-95bd-b9e5-913b7fd9b596'
'x-envoy-attempt-count', '1'
'user-agent', 'Chrome'  # header.request.set.user-agent 参数
'x-b3-traceid', 'bda577f15668b7a754e1b294369875b7'
'x-b3-spanid', '54e1b294369875b7'
'x-b3-sampled', '1'
'x-envoy-internal', 'true'
'x-forwarded-client-cert', 'By=spiffe://cluster.local/ns/default/sa/default;Hash=66d4f869b122f686023de5e24747066069eb97fe672434b8e04e09d51f590d83;Subject="";URI=spiffe://cluster.local/ns/istio-system/sa/istio-ingressgateway-service-account'

v11 在调用其他容器会继续待用该参数么?

FaQ

upstream_reset_before_response_started{connection_termination} 问题

[2022-08-31T12:10:59.805Z] "GET / HTTP/1.1" 503 UC upstream_reset_before_response_started{connection_termination} - "-" 0 95 4 - "10.244.0.0" "Chrome" "7be5f158-d2ed-9e6c-bb63-e239609e34f1" "site.kb.cx" "10.244.1.22:8080" outbound|8080|v11|site.default.svc.cluster.local 10.244.1.13:59898 10.244.1.13:8080 10.244.0.0:39013 - canary
  • 排查过程

开启 Istio ingressgateway debug 日志级别:

kubectl -n istio-system exec -it istio-ingressgateway-679bf9454b-7m4hh -- curl -XPOST -s -o /dev/null http://localhost:15000/logging?level=debug

查看 kubectl -n istio-system logs -f istio-ingressgateway-679bf9454b-7m4hh 发现错误:

2022-08-31T12:40:11.890424Z	debug	envoy pool	[C18719] client disconnected, failure reason: TLS error: 268436501:SSL routines:OPENSSL_internal:SSLV3_ALERT_CERTIFICATE_EXPIRED 33554464:system library:OPENSSL_internal:Broken pipe

看到是证书过期问题,判断可能因为虚拟机环境,时间不同步导致的,尝试删除 istio-ingressgateway 后重建 pod 修复,命令:

kubectl -n istio-system delete pod/istio-ingressgateway-679bf9454b-7m4hh
本文总阅读量 次 本站总访问量 次 本站总访客数