Accessing nginx-ingress-controller error log

nginx-ingress access logs
kubernetes ingress controller
nginx-ingress helm
err services "ingress-nginx" not found
nginx ingress controller version
nginx-ingress namespace
nginx ingress configmap
install nginx ingress controller

I have set up one Kubernetes master node and 2 workers node. I deployed two web applications as a pod using kubectl. I deployed nginx-ingress-controller ( image: gcr.io/google_containers/nginx-ingress-controller:0.9.0-beta.6) and created a service for the same with nodeport option. How do I access the error logs of the nginx-ingress-controller? I'm able to see error.log under /var/log/nginx/, but it is link to /dev/stderr.

In most cases, you will see that containerized applications spit out their logs to stdout/stderr, which means they are available as container logs. In Kubernetes you can access these logs by means of ie. kubectl logs <pod>

Update: a very nice tool for logs cli browsing - https://github.com/wercker/stern

Logging, To check the Ingress Controller logs – both of the Ingress Controller software and the NGINX access and error logs – run: $ kubectl logs <nginx-ingress-pod> -n  Nginx writes records of its events in two types of logs: access logs and error logs. Access logs write information about client requests, and error logs write information about the server and application issues. This article outlines how to configure and read the Nginx access and error logs. Configuring the Access Log

TL;DR

kubectl logs -n <<ingress_namespace>> <<ingress_pod_name>>

Check the namespace under which the Ingress controller is currently running.

$ kubectl get pods
NAME                                    READY   STATUS    RESTARTS   AGE
helloworld-deployment-7dc448d6b-5zvr8   1/1     Running   1          3d20h
helloworld-deployment-7dc448d6b-82dnt   1/1     Running   1          3d20h

$ kubectl get pods -n kube-system
NAME                                        READY   STATUS    RESTARTS   AGE
kube-apiserver-minikube                     1/1     Running   1          3d20h
nginx-ingress-controller-586cdc477c-rhj9z   1/1     Running   1          3d21h

For me, it happens to be the kube-system namespace on the pod nginx-ingress-controller-586cdc477c-rhj9z.

Now, get the logs just like you would or any other pod using

 kubectl logs -n kube-system nginx-ingress-controller-586cdc477c-rhj9z

Troubleshooting, In most cases, you will see that containerized applications spit out their logs to stdout/stderr, which means they are available as container logs. By default, NGINX writes its events in two types of logs – the error log and the access log. In most of the popular Linux distro like Ubuntu, CentOS or Debian, both the access and error log can be found in /var/log/nginx, assuming you have already enabled the access and error logs in the core NGINX configuration file.

I prefer: kubectl logs -lapp=nginx-ingress

(get the logs of all pods with the label nginx-ingress)

Accessing nginx-ingress-controller error log, What keywords did you search in NGINX Ingress controller issues before filing this one? logs, access_log, /dev/stdout Is this a BUG REPORT or  19 minutes ago Up 19 minutes k8s_nginx-ingress-controller_nginx-ingress-controller-67956bf89d-mqxzt_kube-system_079f31ec-aa37-11e8-ad39-080027a227db_0 Exec into the container $ docker exec -it --user = 0 --privileged d9e1d243156a bash

Installation Guide - NGINX Ingress Controller, In kibana dashboard we found both the error log and access log of ingress controller pod. But whenever we do the "kubectl logs nginx pod" it is  @kirs Access log is disabled for default server (the 404 server) (you can see that by inspecting the generated Nginx configuration, search for access_log off;). Try creating a dummy ingress and execute the same curl command with -H "Host: <the host you configured in your domain>".

Configure NGINX logging and monitoring, This guide will provide basic information on debugging access to your application via logs Get the kubernetes logs for an ingress-nginx pod Edit the ingress-nginx-controller Deployment and set the value of the --default-backend-service flag to the name of the newly created error backend. Edit the ingress-nginx-controller ConfigMap and create the key custom-http-errors with a value of 404,503. Take note of the IP address assigned to the NGINX Ingress controller Service.

NGINX Ingress Controller for Kubernetes, kubectl logs -n nginx-ingress-ns nginx-ingress-controller-blahblahpod. It will allow you to pinpoint the error, and you can see if a new nginx.conf  Default SSL Certificate flag solved the issue as OP mentioned.. In Nginx documentation you can read: NXINX Ingress controller provides the flag --default-ssl-certificate.The secret referred to by this flag contains the default certificate to be used when accessing the catch-all server.

Comments
  • stern is a useful utility for this: kubernetes.io/blog/2016/10/tail-kubernetes-with-stern
  • Yes I did accessed the log using kubectl logs. But I hope it is only stdout logs. It has both stdout and stderr logs? Please confirm.
  • yep, it has both
  • Thanks for your confirmation