Istio virtualservice uri匹配不起作用

问题描述 投票:1回答:2

我是kubernetes和istio的新手。在GKE上,我创建了入口网关和两个虚拟服务。第一个是路由到时髦商店的前端网关,第二个是虚拟服务,它路由到我的世界服务器。但是当我打电话给

curl -v http://35.223.232.224/dummy

,它显示Cannot GET / dummy错误。我已经确定我的虚拟服务正在运行,因为我已经使用Loadbalancer外部IP进行了测试。但是我可以使用http://ingress_ip来调用时髦商店。有人可以帮我吗?

这是我的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
2个回答
2
投票

我的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}`);

0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.