13

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.

X0r0N
  • 245
  • 1
  • 3
  • 7

3 Answers3

13

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

enter image description here

Abe Voelker
  • 310
  • 2
  • 10
  • 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 '19 at 10:54
  • Any idea to do it with the CLI ? – tisc0 Mar 05 '20 at 15:42
7

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

chalex2k
  • 71
  • 1
  • 2
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'.

ConnorJC
  • 939
  • 1
  • 8
  • 20
  • 2
    This is returns an error because it thinks it's looking for a pod rather than an ingress – Sinaesthetic Mar 13 '18 at 03:31
  • The ingress controller is a pod in almost all cases. – ConnorJC Mar 13 '18 at 03: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 '18 at 19:23