docker桌面上的istio Ingress 404

问题描述

我一直试图使用Docker桌面在kubernetes和istio上在macOS上运行本地集群。我使用了bookinfo示例,一切运行正常。

我有自己的服务之一,无法运行它。我试着用邮递员打它,总是得到404。

我无法调试它,我可能只是缺少了一些东西或做了一些愚蠢的事情。 这些是我的Yaml文件

gateway.yaml

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: reeal-gateway
spec:
  selector:
    istio: ingressgateway # use istio default controller
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: reeal
spec:
  hosts:
  - "*"
  gateways:
  - reeal-gateway
  http:
  - match:
    - uri:
        exact: /feed
    route:
    - destination:
        host: feed
        port:
          number: 8080

service.yaml

apiVersion: v1
kind: Service
metadata:
  name: feed
  labels:
    app: feed
    service: feed
spec:
  selector:
    app: feed
  ports:
    - port: 8080
      name: http
---
 apiVersion: v1
 kind: ServiceAccount
 metadata:
  name: reeal-feed
  labels:
    account: feed
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: feed-deployment
  labels:
    app: feed
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: feed
      version: v1
  template:
    metadata:
      labels:
        app: feed
        version: v1
    spec:
      serviceAccountName: reeal-feed
      volumes:
      - name: firestore-key
        secret:
          secretName: firestore-cred
      containers:
      - name: feed-service
        image: reealadmin/feed-service:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
        volumeMounts:
        - name: firestore-key
          mountPath: /var/secrets/google
        env:
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: /var/secrets/google/key.json
      imagePullSecrets:
        - name: regcred

我已经通过使用Nodeport公开了该服务进行了测试,并且可以卷曲并获得相应的响应,但是由于无法正确配置入口,我犯了一些错误。

URL

我在下面使用我的URL。形成的网址为localhost/feed

export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].port}')
export SECURE_INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="https")].port}')


export INGRESS_HOST=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')

echo $INGRESS_HOST
echo $INGRESS_PORT
echo $SECURE_INGRESS_PORT

错误

[2020-08-22T01:01:05.088Z] "GET /feed HTTP/1.1" 404 - "-" "-" 0 19 29 22 "192.168.65.3" "PostmanRuntime/7.26.3" "e5705c53-6e70-9dbe-b831-764f9c7be63e" "localhost" "10.1.0.41:8080" outbound|8080||feed.default.svc.cluster.local 10.1.0.25:40654 10.1.0.25:8080 192.168.65.3:59050 - -

这里真的需要帮助。

解决方法

如果收到404错误,则表示已访问您的应用程序,但没有/feed页面。

您可以更改应用程序以在该contextPath上提供所有内容,或者在VirtualService上进行重写:

http:
  - match:
    - uri:
        exact: /feed
    rewrite:
      uri: /
    route:
    - destination:
        host: feed
        port:
          number: 8080

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...