Istio ServiceEntry的域注册表

时间:2018-08-27 08:16:38

标签: kubernetes istio

现在,我正在测试在Istio上运行应用程序的方案。
我无法访问旧版代码,因此无法更改请求网址。

为此,我制作了一些简单的应用程序。

我不确定Istio上是否可以使用此方案。

我有两个应用程序(订单和客户) 在订购应用程序上,有代码用url“ http://customer-app:8080/customer”调用客户应用程序。

现在,我想使用Istio在K8S上运行两个应用程序。
而且我不想更改我的代码,特别是调用URL。
(我知道我可以使用服务名称调用每个服务。
但我想使用“ customer-service”而非“ customer-app”作为客户服务名称)

我发现有一个可以注册MESH_INTERNAL的VirtualService。
我这样制作yaml文件。

apiVersion: networking.istio.io/v1alpha3   
kind: ServiceEntry   
metadata:  
  name: customer-service-entry  
spec:  
  hosts:  
  - http://customer-app:8080  
  location: MESH_INTERNAL  
  ports:  
  - number: 8080  
    name: http  
    protocol: http  
  endpoints:  
  - address: customer-service  
    ports:  
      http: 8080  

是否可能使用虚拟域?

1 个答案:

答案 0 :(得分:1)

您应该可以使用VirtualService来做到这一点:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: customer-app
spec:
  hosts:
  - customer-app
  http:
  - match:
    - port: 8080
    route:
    - destination:
        host: customer-service
        port:
          number: 9080

您还需要为客户应用定义虚拟K8S服务,以便可以解决该问题:

apiVersion: v1
kind: Service
metadata:
  name: customer-app
spec:
  ports:
  - port: 8080
    name: http