在 Istio 中连接到 MySQL (AWS RDS)

Connection to MySQL (AWS RDS) in Istio

我们遇到一个问题,即在 Istio 服务网格中连接到 AWS RDS 会导致 upstream connect error or disconnect/reset before header。 我们的 Egress 规则如下

 apiVersion: config.istio.io/v1alpha2
 kind: EgressRule
 metadata:
     namespace: <our-namespace>
     name: rds-egress-rule-with
 spec:
     destination:
     service: <RDS End point> 
 ports:
     - port: 80
       protocol: http
     - port: 443
       protocol: https
     - port: 3306
       protocol: https 

与 MySQL 的连接在 EC2 中的独立 MySQL 中工作正常。在没有 Istio 的情况下,与 AWS RDS 的连接工作正常。该问题仅出现在 Istio Service Mesh 中。

我们在禁用相互 TLS 配置中使用 istio。

EgressRule 定义中的协议应该是 tcpservice 应包含 IP 地址或 CIDR 表示法中的 IP 地址范围。

或者,您可以使用 istioctl kube-inject--includeIPRanges 标志来指定 Istio 处理哪些 IP 范围。 Istio 不会干扰未包含的 IP 地址,只会允许流量通过。

参考文献:

  1. https://istio.io/latest/blog/2018/egress-tcp/
  2. https://istio.io/latest/docs/tasks/traffic-management/egress/egress-control/#direct-access-to-external-services