Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Ingress
      • Pod
    • Helm Chart
    • OAuth2 Proxy
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
    • MetalLB
    • Kong Gateway
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Argo Events
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • DevSecOps
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
      • Azure Cloud
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log, Monitor & Tracing
    • DataDog
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
    • NextCloud
  • Toggle search form

[istio] Discover route TCP in Cluster Istio

Posted on December 3, 2021December 7, 2021 By nim No Comments on [istio] Discover route TCP in Cluster Istio

Contents

Toggle
  • 1) Install a few component to testing TCP
  • 2) Check port TCP by paping
  • 3) Sending data into TCP port and recheck.
    • 3.1) Pod to service
    • 3.2) pod to pod
      • 3.2.1) Giving Pod ip to route table of istio
      • 3.2.2) Testing pod to pod with strict mode (mTLS)

1) Install a few component to testing TCP

Các bạn sẽ cùng mình tìm hiểu về tcp trong istio and version hiện tại cho bài lab này istio 1.11.3
Link:
https://www.tetrate.io/blog/understanding-istio-and-tcp-services/
https://istio.io/latest/docs/tasks/security/authorization/authz-tcp/

Trong bài này mình sử dụng luôn namspace default và deploy lên đó 2 workload  sleep and tcp-echo.
tcp-echo workload listens on port 9000, 9001.

Link manifest của sleep and tcp-echo

Và mình có cấu hình thêm envoy accessLog TCP nữa nhé
https://nimtechnology.com/2021/09/05/istio-recheck-envoy-test-cac-features-lien-quan-den-envoy/#431_access_log_TCP

Tổng kết deploy sẽ ntn

2) Check port TCP by paping

Đây pod tcp-echo.

Với test TCP port này thì nếu mình ping thôi thì nó chả có log j cả

3) Sending data into TCP port and recheck.

3.1) Pod to service

Theo như ví dụ:
For example, if you send “world” to tcp-echo, it will reply with hello world. 

kubectl exec "$(kubectl get pod -l app=sleep -n default -o jsonpath={.items..metadata.name})" -c sleep -n default -- sh -c 'echo "port 9000" | nc tcp-echo 9000' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'

Các bạn chú ý màu đỏ là namespace và thay cho đúng nhé.

Hoặc là exec vào container sleep và gõ

sh -c 'echo "port 9000" | nc tcp-echo 9000' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'

Màu đó là tên service:

Chúng ta sem log istio-proxy của pod tcp-echo:

3.2) pod to pod

Giờ mình call vào IP của pod tcp-echo:

Thấy log cũng không có j khác biệt

Giờ mình show route của các pod đã injected istio

root@work-space-u20:~/istio-1.11.2/bin# ./istioctl pc l tcp-echo-5b8f599579-gxcks.default --port 9000
ADDRESS        PORT MATCH                        DESTINATION
10.101.139.132 9000 ALL                          Cluster: outbound|9000||tcp-echo.default.svc.cluster.local
10.109.88.245  9000 Trans: raw_buffer; App: HTTP Route: spin-deck.spinnaker.svc.cluster.local:9000
10.109.88.245  9000 ALL                          Cluster: outbound|9000||spin-deck.spinnaker.svc.cluster.local
NGhĩ là nếu destination IP và port match mới bảng route của istio
thì nó sẽ đi ra theo destination của istio

Mình show route inbound trên con tcp-echo:

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||

Giờ mình thực hiện xoá port 9000 trong service của tcp-echo

ping service và port thì ko được
ping pod ip và port thì ok
Bạn thấy dòng log cuối dùng đã có sự thay đổi.

Workload tcp-echo còn có port 9002 nhưng chúng ta ko config trên deployment hay service.
nên khi muốn call vào workload với pod 9002 thì chỉ có thể call pod IP

TCP_ECHO_IP=$(kubectl get pod "$(kubectl get pod -l app=tcp-echo -n default -o jsonpath={.items..metadata.name})" -n default -o jsonpath="{.status.podIP}")
root@work-space-u20:# echo $TCP_ECHO_IP
10.244.36.252

Giờ có ip của pod thì chiến thôi

kubectl exec "$(kubectl get pod -l app=sleep -n default -o jsonpath={.items..metadata.name})" -c sleep -n default -- sh -c "echo \"port 9002\" | nc $TCP_ECHO_IP 9002" | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'

>>>output
hello port 9002
connection succeeded

Nhìn access log này chúng ta có thể ngầm hiểm, route inbound 9000 đã bị xoá trong bảng route istio vì chúng ta đã xoá mất service.

https://istio.io/latest/docs/ops/configuration/traffic-management/traffic-routing/#headless-services

Mình có đọc bài này:
Ví dụ usecase của bạn Pod to Pod:
Workload A và Workload B đều được injected istio
Workload B có cấu hình Service port B
khi pod A connect to PodB IP. thì trên route istio sẽ ko có IP của pod B. theo mình follow sẽ như sau:
pod A -> OutboundPassthroughClusterIpv4 (istio-proxy A) -> InboundPassthroughClusterIpv4(istio-proxy B) -> workload B.

3.2.1) Giving Pod ip to route table of istio

Vậy nếu bạn muốn trong bảng route của istio có route Pod B thì làm sao nhỉ?

Theo istio “In general, Istio does not configure listeners for each Pod IP, as it works at the Service level. However, to support headless services, listeners are set up for each IP:Port pair in the headless service.“

Thì bạn có thể tạo service headless thì istio sẽ gán Pod IP với service headless vào route của istio
Nếu bạn muốn thấy rõ như nào thì mời bạn xem link bên dưới:
https://nimtechnology.com/2021/11/21/istio-discover-route-inside-istio/#2_Discovery

3.2.2) Testing pod to pod with strict mode (mTLS)

Pod to pod có hoặc động được khi bật strict mode (mTLS) hay không?

[Istio] Security authentication và authorization with ISTIO
Tham khải mTLS strict
root@work-space-u20:~# kubectl exec "$(kubectl get pod -l app=sleep -n default -o jsonpath={.items..metadata.name})" -c sleep -n default -- sh -c 'echo "port 9000" | nc tcp-echo 9000' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
hello port 9000
connection succeeded
root@work-space-u20:~# kubectl exec "$(kubectl get pod -l app=sleep -n default -o jsonpath={.items..metadata.name})" -c sleep -n default -- sh -c 'echo "port 9000" | nc 10.244.36.252 9000' | grep "hello" && echo 'connection succeeded' || echo 'connection rejected'
connection rejected

Khi bật mTLS với strict mode thì pod to pod bị fail
Và làm sao làm được pod to pod với strict mode.

Bạn cần tạo service headless cho port và sử dụng cho mục đích pod to pod

không thấy có ip service.
lúc này service headless lấy ip pod và istio đã thu nhận

1 số link github than khảo về docker test tcp&udp
https://github.com/mendhak/docker-udp-listener
https://github.com/sashimi3/tcp-udp-test

Isito-EnvoyFilter

Post navigation

Previous Post: [Jenkins] Scripted Pipeline lesson 4: Stage _ When
Next Post: [istio] There are a few problems inside mode “POD to POD” when using Istio

More Related Articles

[kiali] Config authentication on Kiali. Isito-EnvoyFilter
[Istio] OMG – Metric of an Istiod pod had 2 versions. Why??? Isito-EnvoyFilter
[Istio] Change resource request and limit (RAM-CPU) for components of Istio Isito-EnvoyFilter
[Istio] Explain MutatingWebhookConfiguration to auto-injected istio-proxy. Isito-EnvoyFilter
[Istio/Recheck] Hướng dẫn kiểm tra các feature của cụm istio mới cài lên đã work ngon lành chưa? Isito-EnvoyFilter
[Istio] Workload injected Istio that can’t connect Database(Redis, PostgreSQL) – excludeOutboundPorts or excludeIPRanges Isito-EnvoyFilter

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [WordPress] Hướng dấn gửi mail trên WordPress thông qua gmail. June 15, 2025
  • [Bitbucket] Git Clone/Pull/Push with Bitbucket through API Token. June 12, 2025
  • [Teamcity] How to transfer the value from pipeline A to pipeline B June 9, 2025
  • [Windows] Remove the process that consumes too much CPU. June 3, 2025
  • Deploying Web-Based File Managers: File Browser and KubeFileBrowser with Docker and Kubernetes June 3, 2025

Archives

  • June 2025
  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • BareMetal
    • NextCloud
  • CI/CD
    • Argo Events
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • DevSecOps
    • Golang
    • Jquery & JavaScript
    • Laravel
    • NextJS 14 & ReactJS & Type Script
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • Azure Cloud
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kong Gateway
    • Kubernetes
      • Ingress
      • Pod
    • Longhorn – Storage
    • MetalLB
    • OAuth2 Proxy
    • Vault
    • VictoriaMetrics
  • Log, Monitor & Tracing
    • DataDog
    • ELK
      • Kibana
      • Logstash
    • Fluent
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2025 NimTechnology.