Trong k8s thì bạn biết ràng chúng ta sẽ thiết kế các pod gọi qua nhau thông:
– ingress
– service
Nhưng sẽ có 1 số trường hợp đặt biệt mà mình rút ra ở thực tế và mình tạm gọi là pod to pod
Nghĩ là pod A call sang pod B bằng IP của pod B và đây là mấu chốt để mình tìm hiểu ở đây
1) Introduction
Vậy pod to pod thì có bị istio chặn hay không? thì mình đã trình bày ở bài viết này:
Mình có gặp 1 case khá nguy hiểm.
Pod B có 1 serivce ở pod 8000 và trên app của dev cấu hình allow bind trên ip của pod đó. Chứ dev ko bind 0.0.0.0:8000 hay 127.0.0.1:8000

Trước đó nếu chưa inject istio thì nó sẽ ntn:

Đùng cái bạn injected istio thế là pod B bị 503 các bạn.
Đố các bạn biết tại sao?

2) Discover the inbound traffics through istio.
Mình sẽ có 1 vài links:
https://stackoverflow.com/questions/64979572/in-a-k8s-pod-with-istio-injected-why-envoy-call-localhost-the-packets-pass-prer
https://github.com/istio/istio/wiki/Understanding-IPTables-snapshot#iptables-schematic
root@work-space-u20:~/istio-1.11.2/bin# ./istioctl pc l tcp-echo-5b8f599579-gxcks.default --port 15006
ADDRESS PORT MATCH DESTINATION
0.0.0.0 15006 Addr: *:15006 Non-HTTP/Non-TCP
0.0.0.0 15006 Trans: tls; App: istio-http/1.0,istio-http/1.1,istio-h2; Addr: ::0/0 InboundPassthroughClusterIpv6
0.0.0.0 15006 Trans: tls; Addr: ::0/0 InboundPassthroughClusterIpv6
0.0.0.0 15006 Trans: raw_buffer; Addr: ::0/0 InboundPassthroughClusterIpv6
0.0.0.0 15006 Trans: raw_buffer; App: HTTP; Addr: ::0/0 InboundPassthroughClusterIpv6
0.0.0.0 15006 Trans: tls; App: TCP TLS; Addr: ::0/0 InboundPassthroughClusterIpv6
0.0.0.0 15006 Trans: tls; Addr: 0.0.0.0/0 InboundPassthroughClusterIpv4
0.0.0.0 15006 Trans: raw_buffer; Addr: 0.0.0.0/0 InboundPassthroughClusterIpv4
0.0.0.0 15006 Trans: tls; App: TCP TLS; Addr: 0.0.0.0/0 InboundPassthroughClusterIpv4
0.0.0.0 15006 Trans: raw_buffer; App: HTTP; Addr: 0.0.0.0/0 InboundPassthroughClusterIpv4
0.0.0.0 15006 Trans: tls; App: istio-http/1.0,istio-http/1.1,istio-h2; Addr: 0.0.0.0/0 InboundPassthroughClusterIpv4
0.0.0.0 15006 Trans: tls; App: istio,istio-peer-exchange,istio-http/1.0,istio-http/1.1,istio-h2; Addr: *:9001 Cluster: inbound|9001||
0.0.0.0 15006 Trans: tls; Addr: *:9001 Cluster: inbound|9001||
0.0.0.0 15006 Trans: raw_buffer; Addr: *:9001 Cluster: inbound|9001||
0.0.0.0 15006 Trans: tls; App: istio,istio-peer-exchange,istio-http/1.0,istio-http/1.1,istio-h2; Addr: *:9000 Cluster: inbound|9000||
0.0.0.0 15006 Trans: tls; Addr: *:9000 Cluster: inbound|9000||
0.0.0.0 15006 Trans: raw_buffer; Addr: *:9000 Cluster: inbound|9000||
Ok từ bảng route inbound bên trên thì mình phần làm 2 loại là
There are traffics that Istio understands: InboundPassthroughClusterIpv6, InboundPassthroughClusterIpv4, Cluster: inbound|9001||
There are traffics that Istio doesn’t understand: Non-HTTP/Non-TCP
Mình lấy màu gần giống trong picture của istio
và làm sao để biết được traffic của bạn khi đi qua istio nó hiểu được hay không thì chúng ta mở access log trên workload đó và link này he.
https://nimtechnology.com/2021/09/05/istio-recheck-envoy-test-cac-features-lien-quan-den-envoy/#43_Partially_enable_accesslog
2.1) There are traffics that Istio understands
Với các loại inbount bên dưới và cộng với container chỉ bind trên Pod IP sẽ chị chặn (status 5xx)
InboundPassthroughClusterIpv6, (không cấu hình service port)
InboundPassthroughClusterIpv4, (không cấu hình service port)
Cluster: inbound|9001|| (trường hợp này bạn có cấu hinh service với pod 9001)

Traffic đi vào pod 8000 pod -> đi qua iptable -> forward đến port 15006 -> istio proxy sẽ tranfer tiếp bằng cách gọi 127.0.0.1:8000, để gửi sang bên container App.
Mà IP chỉ bind trên Pod IP (10.42.6.114:8000) thì tạch

2.2) There are traffics that Istio doesn’t understand
Non-HTTP/Non-TCP và và cộng với container chỉ bind trên Pod IP thì nó chả sao cả

Bạn thấy traffic Non-HTTP/Non-TCP thì gọi thằng vào App Container luôn 10.42.6.114:8000
và access log sẽ như thế này:
[2021-12-02T04:36:52.028Z] "- - -" 0 NR "-" "-" 0 0 0 - "-" "-" "-" "-" "-" - - 10.42.20.169:8000 10.42.21.131:50464 - -
[2021-12-02T04:36:52.147Z] "- - -" 0 NR "-" "-" 0 0 0 - "-" "-" "-" "-" "-" - - 10.42.20.169:8000 10.42.21.131:50474 - -
Bạn thấy nó chả có InboundPassthroughClusterIpv6, InboundPassthroughClusterIpv4, Cluster: inbound.
Ngoài ra có các đại ca của mình debug bằng nhiều cách nữa là:
Cũng phải nhờ đến các anh/em thì mình hiểu được
Xin gửi ngàn respect respect respect …. đến anh em.

