kubeedge / edgemesh

Simplified network and services for edge applications
https://edgemesh.netlify.app/
Apache License 2.0
262 stars 134 forks source link

通过gateway的入口访问nginx报404 #509

Open PongY-cumt opened 1 year ago

PongY-cumt commented 1 year ago

What happened: 根据官方文档部署了edgemesh和其中的gateway,官方示例中的hostname-lb-random-gateway-route.yaml能够通过gateway正常访问,但是在VirtualService中多添加了match,指向一个nginx,能访问到是个nginx,但是是404的状态。 我又直接将hostname-lb-random-gateway-route.yaml中的deployment的容器镜像改成nginx,端口改成80,访问nginx,也是404的状态。 image

What you expected to happen:

How to reproduce it (as minimally and precisely as possible): 在edgemesh/examples中将hostname-lb-random-gateway-route.yaml中在VirtualService中多添加了match,指向一个nginx Anything else we need to know?: deployment和service:

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 1
  template:
    metadata:
      labels:
        app: nginx
    spec:
      nodeName: edgenode-1
      containers:
      - name: nginx
        image: nginx:latest
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
          protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
  name: nginx-svc
spec:
  #type: NodePort
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
   # nodePort: 30080
  selector:
    app: nginx

Gateway和VirtualService:

apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: edgemesh-gateway
spec:
  selector:
    kubeedge: edgemesh-gateway

  servers:
    - hosts:
        - 'hostname.org'
      port:
        #name: http-0
        number: 23333
        protocol: HTTP
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: edgemesh-gateway-svc
spec:
  gateways:
    - edgemesh-gateway
  hosts:
    - 'hostname.org'
  http:
    - match:
      - uri:
          prefix: /who
      route:
      - destination:
          host: hostname-lb-svc
          port:
            number: 12345
    - match:
      - uri:
          prefix: /nginx
      route:
      - destination:
          host: nginx-svc
          port:
            number: 80

edgemesh-agent-edgenode日志好像没有什么问题

I1019 10:35:06.911883       1 proxier.go:895] "Opened iptables from-containers public port for service" servicePortName="kubeedge/cloudcore:cloudhub" protocol=TCP nodePort=31505
I1019 10:35:06.921941       1 proxier.go:906] "Opened iptables from-host public port for service" servicePortName="kubeedge/cloudcore:cloudhub" protocol=TCP nodePort=31505
I1019 10:35:06.923569       1 proxier.go:916] "Opened iptables from-non-local public port for service" servicePortName="kubeedge/cloudcore:cloudhub" protocol=TCP nodePort=31505
I1019 10:35:06.937259       1 proxier.go:895] "Opened iptables from-containers public port for service" servicePortName="kubeedge/cloudcore:cloudhub-quic" protocol=TCP nodePort=31493
I1019 10:35:07.008042       1 proxier.go:906] "Opened iptables from-host public port for service" servicePortName="kubeedge/cloudcore:cloudhub-quic" protocol=TCP nodePort=31493
I1019 10:35:07.009564       1 proxier.go:916] "Opened iptables from-non-local public port for service" servicePortName="kubeedge/cloudcore:cloudhub-quic" protocol=TCP nodePort=31493
I1019 10:35:07.023881       1 proxier.go:895] "Opened iptables from-containers public port for service" servicePortName="kubeedge/cloudcore:cloudhub-https" protocol=TCP nodePort=32545
I1019 10:35:07.025066       1 proxier.go:906] "Opened iptables from-host public port for service" servicePortName="kubeedge/cloudcore:cloudhub-https" protocol=TCP nodePort=32545
I1019 10:35:07.027408       1 proxier.go:916] "Opened iptables from-non-local public port for service" servicePortName="kubeedge/cloudcore:cloudhub-https" protocol=TCP nodePort=32545
I1019 10:35:07.042082       1 proxier.go:895] "Opened iptables from-containers public port for service" servicePortName="kubeedge/cloudcore:cloudstream" protocol=TCP nodePort=32388
I1019 10:35:07.104924       1 proxier.go:906] "Opened iptables from-host public port for service" servicePortName="kubeedge/cloudcore:cloudstream" protocol=TCP nodePort=32388
I1019 10:35:07.112387       1 proxier.go:916] "Opened iptables from-non-local public port for service" servicePortName="kubeedge/cloudcore:cloudstream" protocol=TCP nodePort=32388
I1019 10:35:07.126406       1 proxier.go:895] "Opened iptables from-containers public port for service" servicePortName="kubeedge/cloudcore:tunnelport" protocol=TCP nodePort=31870
I1019 10:35:07.132198       1 proxier.go:906] "Opened iptables from-host public port for service" servicePortName="kubeedge/cloudcore:tunnelport" protocol=TCP nodePort=31870
I1019 10:35:07.136410       1 proxier.go:916] "Opened iptables from-non-local public port for service" servicePortName="kubeedge/cloudcore:tunnelport" protocol=TCP nodePort=31870
I1019 11:28:58.137974       1 tunnel.go:126] [MDNS] Discovery found peer: {12D3KooWB5qVCMrMNLpBDfMu6o4dy6ci2UqDVsFVomcd2PfYVzfW: [/ip4/127.0.0.1/tcp/20006 /ip4/192.168.245.130/tcp/20006 /ip4/192.168.122.1/tcp/20006]}
I1019 11:28:58.215866       1 tunnel.go:156] [MDNS] New stream between peer {12D3KooWB5qVCMrMNLpBDfMu6o4dy6ci2UqDVsFVomcd2PfYVzfW: [/ip4/127.0.0.1/tcp/20006 /ip4/192.168.245.130/tcp/20006 /ip4/192.168.122.1/tcp/20006]} success
I1019 11:28:58.323626       1 tunnel.go:192] [MDNS] Discovery to k8s-master : {12D3KooWB5qVCMrMNLpBDfMu6o4dy6ci2UqDVsFVomcd2PfYVzfW: [/ip4/127.0.0.1/tcp/20006 /ip4/192.168.245.130/tcp/20006 /ip4/192.168.122.1/tcp/20006]}

edgemesh-getaway日志:

192.168.245.132是edgenode的IP

E1019 11:19:52.617617       1 server.go:86] get conn error: accept tcp 127.0.0.1:23333: use of closed network connection
E1019 11:19:52.617708       1 server.go:86] get conn error: accept tcp 192.168.245.132:23333: use of closed network connection
E1019 11:19:52.617730       1 server.go:86] get conn error: accept tcp 192.168.122.1:23333: use of closed network connection
E1019 11:19:52.617742       1 server.go:86] get conn error: accept tcp 172.17.0.1:23333: use of closed network connection
E1019 11:19:52.617753       1 server.go:86] get conn error: accept tcp 169.254.96.16:23333: use of closed network connection
I1019 11:19:52.618066       1 gateway.go:157] gateway `default.edgemesh-gateway` update server on 127.0.0.1:23333
I1019 11:19:52.618089       1 gateway.go:157] gateway `default.edgemesh-gateway` update server on 192.168.245.132:23333
I1019 11:19:52.618101       1 gateway.go:157] gateway `default.edgemesh-gateway` update server on 192.168.122.1:23333
I1019 11:19:52.618112       1 gateway.go:157] gateway `default.edgemesh-gateway` update server on 172.17.0.1:23333
I1019 11:19:52.618124       1 gateway.go:157] gateway `default.edgemesh-gateway` update server on 169.254.96.16:23333

E1019 10:26:07.516758       1 http.go:56] route by http request uri err: no match svc found for uri /favicon.ico
E1019 10:26:07.517643       1 http.go:56] route by http request uri err: no match svc found for uri /favicon.ico
E1019 10:26:07.518392       1 http.go:56] route by http request uri err: no match svc found for uri /favicon.ico
I1019 10:26:07.642776       1 tcp.go:30] destination service is default/hostname-lb-svc:http-0
I1019 10:26:07.642982       1 loadbalancer.go:720] Dial legacy network between hostname-lb-edge-5cdf5c758c-ndq7w - {tcp edgenode-1 172.17.0.5:9376}
E1019 10:26:07.703872       1 http.go:56] route by http request uri err: no match svc found for uri /favicon.ico
E1019 10:26:07.704772       1 http.go:56] route by http request uri err: no match svc found for uri /favicon.ico
E1019 10:26:07.705643       1 http.go:56] route by http request uri err: no match svc found for uri /favicon.ico
I1019 10:26:10.863324       1 tcp.go:30] destination service is default/nginx-svc
I1019 10:26:10.863557       1 loadbalancer.go:720] Dial legacy network between nginx-5bbcc7f78f-lb7fw - {tcp edgenode-1 172.17.0.3:80}

Environment:

biao-lvwan commented 9 months ago

请问你的gateway部署节点在公网嘛,不是公网可以部署嘛