连接到Istio入口网关会出现404错误

时间:2019-04-07 05:56:01

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

我使用可用的舵表安装了istio v1.1.1

我有

$ kubectl get svc istio-ingressgateway -n istio-system
NAME                   TYPE           CLUSTER-IP     EXTERNAL-IP     PORT(S)                                                                                                                                      AGE
istio-ingressgateway   LoadBalancer   10.31.251.20   35.189.53.230   80:31380/TCP,443:31390/TCP,31400:31400/TCP,15029:31920/TCP,15030:32305/TCP,15031:31084/TCP,15032:31163/TCP,15443:32714/TCP,15020:30964/TCP   3h

然后,我创建了如下网关和虚拟服务:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: myservice-gateway
  namespace: stg
spec:
  selector:
    istio: ingressgateway # use Istio default gateway implementation
  servers:
  - hosts:
    - "stg.myservice.com"
    port:
      number: 80
      protocol: http
      name: http-myservice-port


---      

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: myservice
  namespace: stg
spec:
  hosts:
    - "stg.myservice.com"
  gateways:
  - myservice-gateway         
  http:
  - match:
    - uri:
        prefix: /
    route:
    - destination:
        port:
          number: 8888
        host: myservice-service.stg.svc.cluster.local

我已确保服务正常运行,并且在转发Pod时,可以使用localhost访问它。

我可以确认stg.myservice.com解析为35.189.53.230。 我收到此错误

$ curl -i stg.myservice.com
HTTP/1.1 404 Not Found
location: http://stg.myservice.com/
date: Sun, 07 Apr 2019 05:54:59 GMT
server: istio-envoy
content-length: 0

我想念什么?

我在ingress-gateway窗格中没有看到错误

PS:我有gateways.istio-ingressgateway.sds.enabled=true

1 个答案:

答案 0 :(得分:1)

在您的virtualservice配置中,您需要向网关添加名称空间

stg/myservice-gateway 

代替

myservice-gateway   

类似这样

apiVersion: networking.istio.io/v1alpha3 kind: VirtualService metadata: name: myservice namespace: stg spec: hosts: - "stg.myservice.com" gateways: - stg/myservice-gateway
http: - match: - uri: prefix: / route: - destination: port: number: 8888 host: myservice-service.stg.svc.cluster.local