Kubernetes-ingress: 502 Bad Gateway

Created on 20 Nov 2018  路  5Comments  路  Source: nginxinc/kubernetes-ingress

Hi,

We just followed this tutorial and created two services: nginx1-7, nginx1-8.
However, we found that the ingress nginx container is not forwarding the http request to the correct backend server (502 Bad Gateway is returned to the client).

This is the error log got from docker logs <container_id>

2018/11/20 17:57:10 [error] 5999#5999: *85 connect() failed (111: Connection refused) while connecting to upstream, client: 10.244.0.1, server: cafe.example.c
om, request: "GET /tea HTTP/1.1", upstream: "http://127.0.0.1:8181/tea", host: "cafe.example.com"

The upstream ip and port is not same as the target service pods, it is still same as the default values at nginx.go#L182.

The following is my ingress config:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test
spec:
  rules:
  - host: cafe.example.com
    http:
      paths:
      - path: /tea
        backend:
          serviceName: nginx1-7
          servicePort: 80
  - host: n18.my.com
    http:
      paths:
      - path: /cat
        backend:
          serviceName: nginx1-8
          servicePort: 80

Could you please help us to figure out?

Most helpful comment

@edingroot I'd appreciate if you could post how you solved your issue

All 5 comments

@edingroot
It looks like the Ingress Controller cannot find the endpoints of your services. Note that the services must be in the same namespace as the Ingress resource and have the same port as the port referenced in the servicePort field. Could you share the manifests of your services and deployments as well?

Are there any other errors in the logs? Could you possibly increase the verbosity of the logs to 3 (via -v argument of the IC https://github.com/nginxinc/kubernetes-ingress/blob/master/docs/cli-arguments.md) and share the logs as well?

Hi @pleshakov ,

I finally found that I misconfigured the service name as the app name in the pod. It works now.

Thank you very much for you help!

@edingroot I'd appreciate if you could post how you solved your issue

@edingroot Please post how you solved it

Hi guys, sorry that I didn't notice your reply.
Sadly the original tutorial has gone, but I think I just forgot to set the correct name of metadata->name field in the Pod's yaml config at that time. Hope this helps.

Was this page helpful?
0 / 5 - 0 ratings