gensheng
gensheng

Reputation: 73

k8s ingress can't route to service

I install nginx ingress on k8s cluster , happend a unslovable problem on ingress route.

There are 3 service backend on k8s cluster : 2 nginx service an 1 neo4j service .

My ingress describe info is follow :

[root@es3 cafe_ingress]# kubectl describe ingress cafe-ingress
Name:             cafe-ingress
Namespace:        default
Address:          192.168.59.155
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
TLS:
  cafe-secret terminates cafe.example.com
Rules:
  Host              Path  Backends
  ----              ----  --------
  cafe.example.com
                    /tea      tea-svc:80 (10.244.0.25:80,10.244.1.11:80,10.244.2.15:80)
                    /coffee   coffee-svc:80 (10.244.0.24:80,10.244.2.14:80)
                    /neo4j    neo4j-v1-service:7474 (10.244.0.29:7474)
Annotations:        Events:
  Type              Reason  Age               From                      Message
  ----              ------  ----              ----                      -------
  Normal            CREATE  22m               nginx-ingress-controller  Ingress default/cafe-ingress
  Normal            UPDATE  5s (x3 over 22m)  nginx-ingress-controller  Ingress default/cafe-ingress

And , I access tea or coffee service , this ingress on route coffee or tea, it works correctly, I can get response from service tea or coffee on browser : enter image description here enter image description here

However , where access of neo4j, I can't get response : enter image description here

From pod nginx-ingress-controller log output messages, got 404 code , follow :

2020-12-17T07:28:10.861510393Z 10.244.0.0 - - [17/Dec/2020:07:28:10 +0000] "GET /neo4j HTTP/1.1" 404 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36" 480 0.004 [default-neo4j-v1-service-7474] [] 10.244.0.29:7474 0 0.005 404 17a02ccd8a65d5ff396c78e819f3c4cc

However,when I access the neo4j service , execute command line curl 10.244.0.29:7474 (pod url) or curl 10.0.0.100:7474(service url), I can get response :

[root@es3 cafe_ingress]# curl 10.244.0.29:7474
{
  "bolt_routing" : "neo4j://10.244.0.29:7687",
  "transaction" : "http://10.244.0.29:7474/db/{databaseName}/tx",
  "bolt_direct" : "bolt://10.244.0.29:7687",
  "neo4j_version" : "4.2.1",
  "neo4j_edition" : "community"
}[root@es3 cafe_ingress]# curl 10.0.0.100:7474
{
  "bolt_routing" : "neo4j://10.0.0.100:7687",
  "transaction" : "http://10.0.0.100:7474/db/{databaseName}/tx",
  "bolt_direct" : "bolt://10.0.0.100:7687",
  "neo4j_version" : "4.2.1",
  "neo4j_edition" : "community"
}

How can I fix this problem ? Look forward for your help , thanks !

Upvotes: 0

Views: 801

Answers (1)

gensheng
gensheng

Reputation: 73

The problem has been fixed . Reason of problem is the backend service of neo4j missing resource on path /neo4j. There is the problematic config of my ingress :

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: cafe-ingress
spec:
  rules:
  - host: cafe.example.com
    http:
      paths:
      - path: /tea
        backend:
          serviceName: tea-svc
          servicePort: 80
      - path: /coffee
        backend:
          serviceName: coffee-svc
          servicePort: 80
      - path: /neo4j
        backend:
          serviceName: neo4j-v1-service
          servicePort: 7474

And then , reconfig it , making it has it's owner domain , point / to service of neo4j , It works correctly .

The new config of ingress is follow :

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: cafe-ingress
spec:
#  tls:
#  - hosts:
#    - cafe.example.com
#    secretName: cafe-secret
  rules:
  - host: cafe.example.com
    http:
      paths:
      - path: /tea
        backend:
          serviceName: tea-svc
          servicePort: 80
      - path: /coffee
        backend:
          serviceName: coffee-svc
          servicePort: 80
  - host: neo4j.xxx.com
    http:
      paths:
      - path: /
        backend:
          serviceName: neo4j-v1-service
          servicePort: 7474

Upvotes: 1

Related Questions