【问题标题】:Istio virtualservice uri match not workingIstio 虚拟服务 uri 匹配不起作用
【发布时间】:2019-11-20 03:40:24
【问题描述】:

我是 Kubernetes 和 istio 的新手。在 GKE 上,我创建了入口网关和两个虚拟服务。第一个是路由到 hipstershop 的前端网关,第二个是路由到我的 hello world 服务器的 dummyservice。但是当我打电话时

curl -v http://35.223.232.224/dummy

,它显示 Cannot GET /dummy 错误。我确定我的 dummyservice 工作正常,因为我已经使用 Loadbalancer 外部 IP 进行了测试。但是我可以使用 http://ingress_ip 致电 hipstershop。有人可以帮我吗?

这是我的 istio 配置文件

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: frontend-gateway
spec:
  selector:
    istio: ingressgateway # use Istio default gateway implementation
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: dummy-ingress
spec:
  hosts:
  - "*"
  gateways:
  - frontend-gateway                
  http:
  - match:
    - uri:
        exact: /dummy
    route:
    - destination:
        host: dummyservice            
        port:
          number: 80

---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: dummy-ingress2
spec:
  hosts:
  - "*"
  gateways:
  - frontend-gateway                
  http:
  - match:
    - uri:
        exact: /dummy2
    route:
    - destination:
        host: dummyservice            
        port:
          number: 80

---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: frontend-ingress
spec:
  hosts:
  - "*"
  gateways:
  - frontend-gateway
  http:
  - route:
    - destination:
        host: frontend
        port:
          number: 80

【问题讨论】:

    标签: google-kubernetes-engine kubernetes-ingress istio


    【解决方案1】:

    我的 dummyservice node.js 服务器仅在“/”网址上提供服务。所以返回的错误 404 不是来自入口,而是来自我的 node.js 服务器。在节点服务器中更改我的基本路由解决了这个问题。

    'use strict';
    
    const express = require('express');
    
    // Constants
    const PORT = 80;
    const HOST = '0.0.0.0';
    
    // App
    const app = express();
    app.get('/dummy', (req, res) => {
      res.send('Hello world\n');
    });
    
    app.listen(PORT, HOST);
    console.log(`Running on http://${HOST}:${PORT}`);
    

    【讨论】:

      【解决方案2】:

      仅供参考:Kaili 和 Jaeger 可以与 Istio 一起安装,并且可以为您提供有关服务网格中的流量的信息

      【讨论】:

        猜你喜欢
        • 2019-09-14
        • 2021-10-18
        • 2021-09-21
        • 2019-12-21
        • 2019-07-19
        • 2020-09-07
        • 1970-01-01
        • 2021-08-20
        • 1970-01-01
        相关资源
        最近更新 更多