1

I'm trying to troubleshoot a 404 message on my ingress. When I view logs using kubectl logs -n ingress-nginx ingress-nginx-controller-xxxxxx -f I don't see any output when making a request to the URL. Is there a specific setting that allows me to see access/error logs?

I'm looking for what I would normally see when viewing /var/log/nginx/error.log or /var/log/nginx/access.log.

3
  • Are you using regular Kubernetes or some managed service? – Michael Hampton Aug 4 '20 at 18:34
  • I'm using Azure Kubernetes Services (AKS). – Ben Davis Aug 4 '20 at 19:00
  • If you exec into those Pods, are those two paths (a) the current values of error_log and (b) are they actually files, or are they symlinks to /dev/stdout or perhaps /proc/1/fd/0? – mdaniel Aug 5 '20 at 4:46
2

You can exec into the pods using kubectl exec <pod_name> -n <namespace> <command> and check if your application is creating log files in the paths that you have mentioned. If you are able to verify the existence of those files, you can add a busybox sidecar to the deployment and you can directly stream your logs using the sidecar and tail them using kubectl logs

You can use the following template to do the same:

Add the following volume-mount to the existing deployment

volumeMounts:
  - mountPath: /var/log/nginx
    name: logging-mount

And then you can add the sidecar using the following template

- name: log-streaming-sidecar
  image: busybox
  args: [/bin/sh, -c, 'tail -n+1 -f /var/log/nginx/*']
  volumeMounts:
     - mountPath: /var/log/nginx
       name: logging-mount
volumes:
  - name: logging-mount
    emptyDir: {}

Please note that this will stream both your error and access logs into the same stream. Although, the correct method to do this is to create symlinks for error and access logs, the method I have mentioned can be used as an alternative.

Hope this helps!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.