kumahq / kuma-demo

A demo app to illustrate the capabilities and advantages of Kuma. 🐻
https://kuma.io/
Apache License 2.0
58 stars 54 forks source link

Can not connect to the backend. #164

Closed fabian4 closed 9 months ago

fabian4 commented 10 months ago

What happened?

Just start learning kuma and find it doesn't work as I expect.

image

logs from pod [kuma-fe]

[2024-01-18T15:46:59.963Z] "GET /items?q=dvadafbgaasdgargasgeargb" Error (404): "socket hang up"
[2024-01-18T15:46:59.963Z] "GET /items?q=dvadafbgaasdgargasgeargb" Error (404): "Not found"
[2024-01-18T15:46:59.963Z] "GET /items?q=dvadafbgaasdgargasgeargb" Error (404): "Not found"
[2024-01-18T15:46:59.963Z] "GET /items?q=dvadafbgaasdgargasgeargber" Error (404): "socket hang up"
[2024-01-18T15:46:59.963Z] "GET /items?q=dvadafbgaasdgargasgeargber" Error (404): "Not found"
[2024-01-18T15:46:59.963Z] "GET /items?q=dvadafbgaasdgargasgeargber" Error (404): "Not found"
[2024-01-18T15:46:59.963Z] "GET /items?q=dvadafbgaasdgargasgeargberb" Error (404): "socket hang up"
[2024-01-18T15:46:59.963Z] "GET /items?q=dvadafbgaasdgargasgeargberb" Error (404): "Not found"
[2024-01-18T15:46:59.963Z] "GET /items?q=dvadafbgaasdgargasgeargberb" Error (404): "Not found"
[2024-01-18T15:46:59.963Z] "GET /items?q=dvadafbgaasdgargasgeargb" Error (404): "socket hang up"
[2024-01-18T15:46:59.963Z] "GET /items?q=dvadafbgaasdgargasgeargb" Error (404): "Not found"
[2024-01-18T15:46:59.964Z] "GET /items?q=dvadafbgaasdgargasgeargb" Error (404): "Not found"
[2024-01-18T15:46:59.964Z] "GET /items?q=dvadafbgaasdgargasgeargberbd" Error (404): "socket hang up"
[2024-01-18T15:46:59.964Z] "GET /items?q=dvadafbgaasdgargasgeargberbd" Error (404): "Not found"
[2024-01-18T15:46:59.964Z] "GET /items?q=dvadafbgaasdgargasgeargberbd" Error (404): "Not found"
➜  ~ kumactl get traffic-permissions
MESH      NAME                  AGE
default   backend-to-postgres   10m
default   backend-to-redis      9m
default   frontend-to-backend   10m
default   kong-to-frontend      10m
➜  ~
➜  ~ kubectl get pods -n kuma-demo
NAME                                   READY   STATUS    RESTARTS   AGE
kuma-demo-backend-v0-56dd45c8d-gqvb2   2/2     Running   0          26m
postgres-master-bd8696f6c-mxzbd        2/2     Running   0          26m
redis-master-fc564bf85-hbhnz           2/2     Running   0          26m
kuma-demo-app-66468cb454-9777c         2/2     Running   0          26m
➜  ~
➜  ~ kumactl inspect dataplanes
MESH      NAME                                             TAGS                                                                                                                                                                                                                                        STATUS   LAST CONNECTED AGO   LAST UPDATED AGO   TOTAL UPDATES   TOTAL ERRORS   CERT REGENERATED AGO   CERT EXPIRATION       CERT REGENERATIONS   CERT BACKEND   SUPPORTED CERT BACKENDS   KUMA-DP VERSION   ENVOY VERSION   DEPENDENCIES VERSIONS   NOTES
default   kuma-demo-app-66468cb454-9777c.kuma-demo         app=kuma-demo-frontend env=prod k8s.kuma.io/namespace=kuma-demo k8s.kuma.io/service-name=frontend k8s.kuma.io/service-port=8080 kuma.io/protocol=http kuma.io/service=frontend_kuma-demo_svc_8080 pod-template-hash=66468cb454 version=v8   Online   26m                  9m                 29              0              22m                    2024-01-19 23:31:55   1                    ca-1           ca-1                      2.5.1             1.28.0          -
default   kuma-demo-backend-v0-56dd45c8d-gqvb2.kuma-demo   app=kuma-demo-backend env=prod k8s.kuma.io/namespace=kuma-demo k8s.kuma.io/service-name=backend k8s.kuma.io/service-port=3001 kuma.io/protocol=http kuma.io/service=backend_kuma-demo_svc_3001 pod-template-hash=56dd45c8d version=v0       Online   26m                  11m                26              0              22m                    2024-01-19 23:31:55   1                    ca-1           ca-1                      2.5.1             1.28.0          -
default   postgres-master-bd8696f6c-mxzbd.kuma-demo        app=postgres k8s.kuma.io/namespace=kuma-demo k8s.kuma.io/service-name=postgres k8s.kuma.io/service-port=5432 kuma.io/protocol=tcp kuma.io/service=postgres_kuma-demo_svc_5432 pod-template-hash=bd8696f6c                                   Online   26m                  11m                26              0              22m                    2024-01-19 23:31:55   1                    ca-1           ca-1                      2.5.1             1.28.0          -
default   redis-master-fc564bf85-hbhnz.kuma-demo           app=redis k8s.kuma.io/namespace=kuma-demo k8s.kuma.io/service-name=redis k8s.kuma.io/service-port=6379 kuma.io/protocol=tcp kuma.io/service=redis_kuma-demo_svc_6379 pod-template-hash=fc564bf85 role=master tier=backend                   Online   26m                  10m                26              0              22m                    2024-01-19 23:31:55   1                    ca-1           ca-1                      2.5.1             1.28.0          -
➜  ~

Is there anything I can do to find out what's going on?

BTW the image link in https://github.com/kumahq/kuma-demo/blob/master/kubernetes/README.md all failed.

jakubdyszkiewicz commented 10 months ago

Triage: Hey, a couple of questions

  • Can you post YAML of all traffic-permissions (kumactl get traffic-permissions -o yaml)
  • Does it happen also when you open a page or just on search?
fabian4 commented 10 months ago
  1. Here is the full output

    ➜  ~ kumactl get traffic-permissions -o yaml
    items:
    - creationTime: "2024-01-18T15:42:48Z"
    destinations:
    - match:
      kuma.io/service: postgres_kuma-demo_svc_5432
    mesh: default
    modificationTime: "2024-01-18T15:42:48Z"
    name: backend-to-postgres
    sources:
    - match:
      kuma.io/service: backend_kuma-demo_svc_3001
    type: TrafficPermission
    - creationTime: "2024-01-18T15:43:47Z"
    destinations:
    - match:
      kuma.io/service: redis_kuma-demo_svc_6379
    mesh: default
    modificationTime: "2024-01-18T15:43:47Z"
    name: backend-to-redis
    sources:
    - match:
      kuma.io/service: backend_kuma-demo_svc_3001
    type: TrafficPermission
    - creationTime: "2024-01-18T15:42:48Z"
    destinations:
    - match:
      kuma.io/service: backend_kuma-demo_svc_3001
    mesh: default
    modificationTime: "2024-01-18T15:42:48Z"
    name: frontend-to-backend
    sources:
    - match:
      kuma.io/service: frontend_kuma-demo_svc_8080
    type: TrafficPermission
    - creationTime: "2024-01-18T15:42:48Z"
    destinations:
    - match:
      kuma.io/service: frontend_kuma-demo_svc_8080
    mesh: default
    modificationTime: "2024-01-18T15:42:48Z"
    name: kong-to-frontend
    sources:
    - match:
      kuma.io/service: kong-validation-webhook_kuma-demo_svc_443
    type: TrafficPermission
    next: null
    total: 4
  2. And It happens once you start the pod (here is the full detail log

    Starting up http-server, serving /dist
    Available on:
    http://127.0.0.1:8080
    http://10.42.0.107:8080
    Unhandled requests will be served from: http://backend_kuma-demo_svc_3001.mesh
    Hit CTRL-C to stop the server
    [2024-01-24T16:39:53.692Z] "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
    (node:1) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
    [2024-01-24T16:39:53.771Z] "GET /items?q" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
    [2024-01-24T16:39:54.820Z] "GET /items?q" Error (404): "connect ECONNREFUSED 198.18.5.186:80"
    [2024-01-24T16:39:54.820Z] "GET /items?q" Error (404): "Not found"
    [2024-01-24T16:39:54.820Z] "GET /items?q" Error (404): "Not found"
    [2024-01-24T16:40:00.914Z] "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
    [2024-01-24T16:40:00.957Z] "GET /items?q" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
    [2024-01-24T16:40:00.961Z] "GET /items?q" Error (404): "connect ECONNREFUSED 198.18.5.186:80"
    [2024-01-24T16:40:00.961Z] "GET /items?q" Error (404): "Not found"
    [2024-01-24T16:40:00.961Z] "GET /items?q" Error (404): "Not found"
    [2024-01-24T16:40:01.752Z] "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
    [2024-01-24T16:40:01.846Z] "GET /items?q" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
    [2024-01-24T16:40:01.848Z] "GET /items?q" Error (404): "connect ECONNREFUSED 198.18.5.186:80"
fabian4 commented 10 months ago

I figured it out !!!!

[2024-01-24T16:40:01.848Z] "GET /items?q" Error (404): "connect ECONNREFUSED 198.18.5.186:80"

The DNS request has been solved by my router outside the cluster Which has a fake-ip policy runs on it. I think there is a DNS server in the cluster and that is the one really responsible for the service in the cluster? or how to configure it to make it right help.

BTW Thanks a lot for your time @jakubdyszkiewicz