在k8s集群中通过入口公开服务时找不到404页

时间:2019-03-06 09:43:47

标签: kubernetes-helm

我有一个RESTFull服务运行在k8s集群(1-master,2-nodes)上,该集群由golang编写,并且具有GET方法,什么也不返回。我想通过Ingress公开它。 当我通过头盔安装好它并安装了两个吊舱之后,我尝试从客户端发送请求(卷曲)。但它返回404错误。当我在nginx-ingress-controller pod中卷曲RESTFull服务时,该服务运行良好。

Restfull和Nginx入口服务

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

入口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 http://10.106.34.249:80/steews/get -kL
404: Page Not Found

入口控制器日志显示请求已收到,并向客户端重新运行404错误。这样,问题就来了,为什么Ingress找不到配置的路径“ / steews”并正确返回它?

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*

nginx-ingress-controller容器中的卷曲,它工作正常。

 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

0 个答案:

没有答案