首页 > 解决方案 > GKE/Istio:外部世界无法连接到私有集群中的服务

问题描述

我通过 Cloud Console UI 使用 Istio 创建了一个私有 GKE 集群。该集群设置了 VPC 对等互连,以便能够访问另一个 Google Cloud 项目中的另一个私有 GKE 集群。

我在命名空间website中的 Kubernetes 中创建了一个带有服务的部署(称为 )staging。我的目标是使用 Envoy 代理通过 Istio 向外界公开这项服务。我已经按照本指南VirtualService创建了必要的内容并Gateway这样做了。

当运行“kubectl exec ...”访问私有集群中的 pod 时,我可以成功连接到website服务的内部 IP 地址,并以“curl”查看该服务的输出。

我已经设置了一个 NAT 网关,因此私有集群中的 pod 可以连接到 Internet。我通过从podcurl中输入各种非 Google 网页来确认这一点。website

但是,正如上面的指南所述,我无法使用website服务的从外部连接到服务。相反,-ing 会导致超时。External IPistio-ingressgatewaycurlExternal IP

我已将所有相关资源的完整 YAML 配置放在一个私有 Gist 中,这里:https ://gist.github.com/marceldegraaf/0f36ca817a8dba45ac97bf6b310ca282

我想知道我的配置中是否缺少某些内容,或者我的用例实际上是不可能的?

标签: kubernetesgoogle-kubernetes-engineistio

解决方案


查看您的要点,我怀疑问题出Gatewayistio-ingressgateway.

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: website-gateway
  namespace: staging
  labels:
    version: v1
spec:
  selector:
    istio: ingressgateway
  servers:
    - port:
        number: 80
        name: http
        protocol: HTTP
      hosts:
        - "*"

特别是我不相信这selector部分是正确的。

您应该能够
kubectl describe po -n istio-system istio-ingressgateway-rrrrrr-pppp
在 Istio Ingress Gateway pod 中找出选择器尝试匹配的内容。


推荐阅读