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
    • Helm Chart
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log & Monitor
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
  • 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

  • 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

[Istio] Canary Upgrade Istio by Operator. This way is very easy!! Isito-EnvoyFilter
[Istio] why does workload inject Istio that workload always connects fail database? – hold Application 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
[kiali] Config authentication on Kiali. Isito-EnvoyFilter
[kiali/istio] Fix issue Configured: configmaps “istio” not found Isito-EnvoyFilter
[Istio] Analyzing Istio Performance by pprof 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

  • [Smartctl] Instruction check the health disk of Raspberry. January 16, 2023
  • [kubectl/Argocd] How to create a kubectl config file for serviceaccount or from the cluster secret of Argocd January 12, 2023
  • [Helm/Github] Create a public Helm chart repository with GitHub Pages January 8, 2023
  • [AWS] How to increase the disk size of a Windows EC2 machine? January 4, 2023
  • [Redis] ElastiCache-Redis Cross-Region Replication|Global DataStore January 3, 2023

Archives

  • 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
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • Golang
    • Jquery & JavaScript
    • Laravel
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kubernetes
      • Ingress
    • Longhorn – Storage
    • Vault
    • VictoriaMetrics
  • Log & Monitor
    • ELK
      • Kibana
      • Logstash
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2023 NimTechnology.