首页 > 解决方案 > Istio ServiceEntry 作为虚拟主机和 VirtualService 可能吗?

问题描述

我有一个用例,我想使用 ServiceEntries 作为虚拟主机来为每个虚拟主机路由和配置目标规则。

(丑陋的)系统设置是:Kubernetes Service 调用一个外部 API(一个主机,一个 URI,不同的上游,由外部系统中的承载令牌路由)。我想在不同的“虚拟主机”之间切换 kubernetes 服务,并为每个虚拟主机配置连接限制以保护不同的外部上游。

Istio DNS 和 CNI 功能已激活。我尝试了类似以下的方法:

apiVersion: networking.istio.io/v1alpha3
kind: ServiceEntry
metadata:
  name: upstream-1
spec:
  hosts:
    - upstream-1
  ports:
    - number: 80
      name: http
      protocol: HTTP
  resolution: DNS
  location: MESH_EXTERNAL
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: upstream-1
spec:
  hosts:
    - upstream-1
  http:
    - route:
        - destination:
            host: httpbin.org
      rewrite:
        authority: httpbin.org
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: upstream-1
spec:
  host: upstream-1
  trafficPolicy:
    connectionPool:
      http:
        h2UpgradePolicy: UPGRADE

我想请求 http://upstream-1 ,它应该被路由到http://httpbin.org并带有主机头“主机:httpbin.org”。并且应该使用 DestinationRule(这里是升级 http 连接的简单示例)。

这可能吗?在此示例中,似乎无法识别虚拟服务。

标签: istio

解决方案


推荐阅读