17

I have recently started to learn about Kubernetes and i'm trying understand why my ingress controller is giving a 502 error.

i'm working with google cloud platform. i can see my service of type: LoadBalancer is working if i connect using its static IP address, but it seems i may not have configured my ingress controller correctly because it gives a 502 error.

but it doesn't display any error when i deploy and i cant find any logs for the Ingress so i cant see why a 502 is being displayed.

2
  • Are you using Google Container Engine (GKE) or Google Compute Engine (GCE)?
    – ConnorJC
    Aug 19, 2017 at 3:38
  • I'm using GKE, but if logs are available for GCE, I'd still like to know in case it is ever useful.
    – X0r0N
    Aug 19, 2017 at 7:17

4 Answers 4

13

On GKE, Ingress logs are in the web console under Stackdriver Logging, under "Cloud HTTP Load Balancer":

enter image description here

2
  • 1
    I don't see "Cloud HTTP Load Balancer" in the dropdown list anymore. I'm having a weird random 502 error and need to check load balancer log, please help.
    – TrungDQ
    Aug 17, 2019 at 10:54
  • Any idea to do it with the CLI ?
    – tisc0
    Mar 5, 2020 at 15:42
8

I got logs in CLI using namespace and label.

kubectl logs -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx

Display ingress labels

kubectl get ingress --show-labels

I found namespace ("ingress-nginx") in the web interface of my cloud platform.

Related: https://stackoverflow.com/questions/46467929/accessing-nginx-ingress-controller-error-log

1

You should be able to view them the same as any other pod (kubectl logs -n namespace-name pod-name). The name and namespace will change depending on which ingress controller you're using.

Be aware that ingress controllers are often setup in a different namespace, so you may need to look for the pod in those. For example, the default configuration of the nginx ingress uses the namespace 'nginx-ingress'.

3
  • 2
    This is returns an error because it thinks it's looking for a pod rather than an ingress Mar 13, 2018 at 3:31
  • The ingress controller is a pod in almost all cases.
    – ConnorJC
    Mar 13, 2018 at 3:40
  • 8
    The GKE Ingress controller runs on a managed master node by GCP, not as a regular pod, so you are not able to view its logs or runa ny kubectl operations on it.
    – Tony
    Jun 27, 2018 at 19:23
0

In my case it was for AWS EKS but that shouldn't matter much. My ingress had no label so @chalex2k's answer didn't work for me. However, I was able to bring up all the events on it at least with: kubectl get events --all-namespaces or kubectl get events -n namespace-name.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .