【问题标题】:Using Istio, is there a way to route ingress to a k8s cluster service that is not running an envoy sidecar?使用 Istio,有没有办法将入口路由到没有运行 envoy sidecar 的 k8s 集群服务?
【发布时间】:2020-01-22 15:01:15
【问题描述】:

我正在运行带有 Windows 和 Linux VM 的 Azure AKS 群集。

我可以从 Istio 命名空间中的 pod 按名称 curl 集群服务,因此我知道到 pod 的 TCP 工作正常。我相信我需要以某种方式通知我的虚拟服务以通过特使代理进行路由,而只是将请求直接转发到 k8s 服务端点 - 类似于它是网格外部的虚拟机.我确实有 TLS 在网关处终止 - k8s 服务本身只是在集群内部的 80 端口上公开。

目前,没有用于 Windows 容器的 envoy sidecar,但从 k8s 的角度来看,这只是 Istio 正在运行的同一集群中的另一个服务。

http-gateway.yaml

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  annotations:
  name: http-gateway
  namespace: istio-system
spec:
  selector:    
    istio: ingressgateway
  servers:
  - hosts:
    - "*.myapp.com"
    port:
      number: 80
      name: http-80-gateway
      protocol: HTTP
    tls:
      httpsRedirect: true # sends 301 redirect for http requests
  - hosts:
    - "*.myapp.com"
    port:
      number: 443
      name: https-443-gateway
      protocol: HTTPS
    tls:
      credentialName: cert-azure-dns
      privateKey: sds
      serverCertificate: sds
      mode: SIMPLE

虚拟服务.yaml

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: myapp-vsvc
  namespace: myapp-ns
spec:
  hosts:
  - foo #external DNS name is foo.myapp.com; gateway host for HTTPS is '*.myapp.com'
  gateways:
  - istio-system/http-gateway
  http:
  - route:
    - destination:
        host: myapp-svc.myapp-ns.svc.cluster.local
        port:
          number: 80

尝试Envoy Passthrough 我添加了如下所示的 ServiceEntry:

apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: myapp-se
  namespace: myapp-ns
spec:
  hosts:
  - myapp-svc.myapp-ns.svc.cluster.local
  ports:
  - number: 80
    name: http
    protocol: HTTP
  resolution: DNS
  location: MESH_EXTERNAL

服务器响应是一个 404,其“server”标头值为“istio-envoy”。

DNS 正确解析到网关并且 acme 证书是有效的 - 所以这个错误通常表明我已将其发送到虚拟服务,但尚未路由到集群服务。在 Kiali 中,我的任何 yaml 定义都没有 Istio 验证错误:虚拟服务、服务入口或网关。

我的 global.outboundTrafficPolicy.mode 设置为“ALLOW_ANY”。

我想知道为集群服务声明“EXTERNAL_MESH”是否有问题? Istio 知道 k8s 服务存在,所以它是否试图优先路由到 envoy sidecar 而忽略我的服务入口注册?

对于特定的 IP 范围有一个 option to bypass envoy altogether,如果我能以某种方式在这个特定的集群服务上设置一个静态 IP,这将是一个选项。我想绕过特使进入这个集群服务。

【问题讨论】:

    标签: azure kubernetes istio azure-aks


    【解决方案1】:

    您可以使用serviceentry 来做到这一点:

    apiVersion: networking.istio.io/v1alpha3
    kind: ServiceEntry
    metadata:
      name: httpbin-ext
    spec:
      hosts:
      - httpbin.org
      ports:
      - number: 80
        name: http
        protocol: HTTP
      resolution: DNS
      location: MESH_EXTERNAL
    

    https://istio.io/docs/tasks/traffic-management/egress/egress-control/

    【讨论】:

    • 我已经更新了这个问题,以反映我尝试使用 ServiceEntry 创建到我的集群服务的直通。该文档指的是控制出口以代理集群外的流量,但我还没有找到尝试将流量输入到没有边车的集群服务的示例。在我的例子中,目标服务在网格外部,但在集群内部。
    【解决方案2】:

    我可以发誓我以前尝试过这个,但显然我需要提供的只是一个简单的虚拟服务没有任何目标规则或服务条目。

    apiVersion: networking.istio.io/v1alpha3
    kind: VirtualService
    metadata:
      name: myapp-vsvc
      namespace: myapp-ns
    spec:
      hosts:
      - foo.myapp.com 
      gateways:
      - istio-system/http-gateway
      http:
      - route:
        - destination:
            host: myapp-svc.myapp-ns.svc.cluster.local
            port:
              number: 80
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-25
      • 1970-01-01
      • 1970-01-01
      • 2012-10-20
      • 2014-12-02
      相关资源
      最近更新 更多