404 page not found when expose service by ingress in k8s cluster

3/6/2019

I have a RESTFull service runs on k8s cluster(1-master, 2-nodes), which writing by golang and it has a GET method and return nothing. I want to expose it by Ingress. After I installed it by helm and 2 pods get up , I tried to send the request(curl) from client. But it return 404 error. When I curl the RESTFull service in nginx-ingress-controller pod, the service works well.

Restfull & nginx-ingress services

NAME                            TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
stee-webservice-svc             NodePort       10.109.22.37     <none>        8080:30009/TCP               47m
nginx-ingress-controller        LoadBalancer   10.106.34.249    <pending>     80:31368/TCP,443:31860/TCP   30h

Ingress Yaml

Name:             nonexistent-raccoon-stee-ws
Namespace:        default
Address:
Default backend:  default-http-backend:80 (<none>)
Rules:
  Host  Path  Backends
  ----  ----  --------
  *
        /steews   stee-webservice-svc:8080 (<none>)
Annotations:
Events:
  Type    Reason  Age                    From                      Message
  ----    ------  ----                   ----                      -------
  Normal  CREATE  52m                    nginx-ingress-controller  Ingress default/nonexistent-raccoon-stee-ws
  Normal  CREATE  52m                    nginx-ingress-controller  Ingress default/nonexistent-raccoon-stee-ws
  Normal  UPDATE  2m27s (x101 over 52m)  nginx-ingress-controller  Ingress default/nonexistent-raccoon-stee-ws
  Normal  UPDATE  2m27s (x101 over 52m)  nginx-ingress-controller  Ingress default/nonexistent-raccoon-stee-ws

curl from client

curl http://10.106.34.249:80/steews/get -kL
404: Page Not Found

The ingress-controller log show the request has been received and did retrun 404 error to client. SO, problem is here, why the Ingress did not find the configed path "/steews" and return it correctly?

10.244.0.0 - [10.244.0.0] - - [06/Mar/2019:09:30:45 +0000] "GET /steews/get HTTP/1.1" 308 171 "-" "curl/7.58.0" 87 0.000 [default-stee-webservice-svc-8080] - - - - 61974b67eb85845faf3177979b851166
10.244.0.0 - [10.244.0.0] - - [06/Mar/2019:09:30:45 +0000] "GET /steews/get HTTP/2.0" 404 19 "-" "curl/7.58.0" 39 0.003 [default-stee-webservice-svc-8080] 10.244.1.38:8080 19 0.004 404 d29b5922d485c36cf0cf6f76b894770b*

curl in nginx-ingress-controller pod, it works fine.

 kc exec -it nginx-ingress-controller-9cf6cf578-qhtl6 -- bash
ww-data@nginx-ingress-controller-9cf6cf578-qhtl6:/etc/nginx$ curl stee-webservice-svc:8080/get -kL -vv
*   Trying 10.109.22.37...
* TCP_NODELAY set
* Connected to stee-webservice-svc (10.109.22.37) port 8080 (#0)
> GET /get HTTP/1.1
> Host: stee-webservice-svc:8080
> User-Agent: curl/7.62.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Wed, 06 Mar 2019 09:24:23 GMT
< Content-Length: 0
<
* Connection #0 to host stee-webservice-svc left intact
-- user3675730
kubernetes-helm

0 Answers