簡體   English   中英

在 GCP 上使用 GKE 的 Istio:無法重定向 TCP stream 除了 80 和 443

[英]Istio with GKE on GCP : impossible to redirect TCP stream other than 80 and 443

我正在將 Istio 與 GKE / GCP 一起使用,並且一切都可以成功地使用帶有 Istio 的經典 HTTPS 部署應用程序。

現在,我正在嘗試為開發集群部署 Kafka,並嘗試將 TCP stream 從特定端口上的 Istio 網關重定向到 kafka,但它不起作用。

我已經從 GCP 檢查了特定的防火牆規則,但目前我認為阻塞點不在這里(一些數據包被 GCP 捕獲並且任何數據包都被阻止,所有端口都被打開)。

我從 6 小時開始就一直在解決這個問題,所以如果有人已經遇到過這個問題,我將非常感激!

我的 Kubernetes 版本是1.17.14-gke.400而 Istio 版本是1.4.10-gke.5

您將在下面找到一個完整的簡化示例,其中包含來自 Istio 的tcp-echo測試:

文件tcp-echo-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: tcp-echo
  namespace: production
spec:
  replicas: 1
  selector:
    matchLabels:
      name: tcp-echo
  template:
    metadata:
      labels:
        name: tcp-echo
    spec:
      containers:
      - name: tcp-echo
        image: istio/tcp-echo-server:1.1
        imagePullPolicy: IfNotPresent
        args: [ "9000", "hello" ]
        ports:
        - containerPort: 9000

文件tcp-echo-service.yaml

apiVersion: v1
kind: Service
metadata:
  name: tcp-echo
  namespace: production
  labels:
    name: tcp-echo
spec:
  ports:
  - name: tcp
    port: 9000
  selector:
    name: tcp-echo

文件tcp-echo-gateway.yaml

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: tcp-echo-gateway
  namespace: istio-system
spec:
  selector:
    istio: ingressgateway
  servers:
  - port:
      number: 10000
      name: tcp
      protocol: TCP
    hosts:
    - "*"

文件tcp-echo-virtual-service.yaml

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: tcp-echo
  namespace: istio-system
spec:
  hosts:
  - "*"
  gateways:
  - tcp-echo-gateway.istio-system.svc.cluster.local
  tcp:
  - match:
    - port: 10000
    route:
    - destination:
        host: tcp-echo.production.svc
        port:
          number: 9000

測試:

$ kubectl apply -f tcp-echo-deployment.yaml
$ kubectl apply -f tcp-echo-service.yaml
$ kubectl apply -f tcp-echo-gateway.yaml
$ kubectl apply -f tcp-echo-virtual-service.yaml

測試 1:集群內部(工作):

$ kubectl -n production run -i --tty busybox --image=busybox --rm=true --restart=Never -- sh
# telnet tcp-echo:9000
  vinz
  hello vinz

測試2:集群外(不工作,ip地址被屏蔽):

$ telnet 1.2.3.4 10000
  Trying 1.2.3.4...

現在我有超時,但幾個小時前我有connection refused

有人已經有這個問題了嗎?

非常感謝 !!

好的,我知道了!

它只是服務“istio-ingressgateway”,它定義並路由來自入口網關的打開的端口。

也許它會幫助某人!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM