gpt4 book ai didi

http-status-code-404 - Istio 入口网关 : 404 NR route_not_found

转载 作者:行者123 更新时间:2023-12-05 01:30:23 25 4
gpt4 key购买 nike

我想配置一个 Istio 入口网关,它根据 HTTP 路径的前缀将流量路由到不同的服务。

例如 HTTP 流量路径 /myservice 应路由到服务 myservice

到目前为止,我已经创建了以下 YAML 配置:

apiVersion: apps/v1
kind: Deployment
metadata:
name: myservice
namespace: microservices
labels:
app: myservice
spec:
replicas: 1
selector:
matchLabels:
app: myservice
template:
metadata:
labels:
app: myservice
spec:
containers:
- name: myservice
image: myservice-node
ports:
- containerPort: 3002
imagePullPolicy: Never
---
apiVersion: v1
kind: Service
metadata:
name: myservice
namespace: microservices
spec:
ports:
- nodePort: 32015
port: 3002
targetPort: 3002
selector:
app: myservice
type: LoadBalancer
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: mygateway
namespace: microservices
spec:
selector:
istio: ingressgateway # use Istio default gateway implementation
servers:
- port:
number: 80
name: http
protocol: HTTP
hosts:
- "host.docker.internal"
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: crossway
namespace: microservices
spec:
hosts:
- "*"
gateways:
- mygateway
http:
- match:
- uri:
prefix: /myservice
route:
- destination:
port:
number: 3002
host: myservice.microservices.svc.cluster.local

http://192.168.99.111:31878/myservice 发送请求产生了 404 错误,如下所示。

$ export INGRESS_HOST=$(minikube ip)
$ export INGRESS_PORT=$(kubectl -n istio-system get service istio-ingressgateway -o jsonpath='{.spec.ports[?(@.name=="http2")].nodePort}')
$ echo "INGRESS_HOST=$INGRESS_HOST, INGRESS_PORT=$INGRESS_PORT"
INGRESS_HOST=192.168.99.111, INGRESS_PORT=31878
$ curl -I http://192.168.99.111:31878/myservice
HTTP/1.1 404 Not Found
date: Sat, 17 Apr 2021 10:54:43 GMT
server: istio-envoy
transfer-encoding: chunked

在入口网关的日志文件中,我发现了以下错误信息:

[2021-04-17T10:54:43.408Z] "HEAD /myservice HTTP/1.1" 404 NR route_not_found - "-" 0 0 0 - "172.17.0.1" "curl/7.64.0" "3b11c571-4372-9b4a-971e-25af260eeba3" "192.168.99.111:31878" "-" - - 172.17.0.4:8080 172.17.0.1:42458 - -

有人知道问题出在哪里吗?

最佳答案

我可以通过将主机的值从“host.docker.internal”更改为“*”来解决问题。

关于http-status-code-404 - Istio 入口网关 : 404 NR route_not_found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67137746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com