nginxinc / kubernetes-ingress

NGINX and NGINX Plus Ingress Controllers for Kubernetes
https://docs.nginx.com/nginx-ingress-controller
Apache License 2.0
4.58k stars 1.96k forks source link

Nginx-plus ingress controller doesnt create symbolic link for access.log for stdout #5569

Open reddyblokesh opened 1 month ago

reddyblokesh commented 1 month ago

Describe the bug Nginx-plus ingress controller doesnt create symbolic link for access.log -> /dev/stdout To Reproduce Steps to reproduce the behavior:

  1. Deploy nginx plus ingress controller using helm charts for version 3.4.3
  2. View logs on k logs -f
  3. no access logs captured rather redirected to /var/log/nginx/access.log

Expected behavior should be able to redirect to stdout and in k logs -f

Your environment

Additional context nginx config has access.log configured: grep access.log /etc/nginx/nginx.conf

access_log  /dev/stdout  main;
access_log syslog:server=unix:/var/lib/nginx/nginx-syslog.sock,nohostname,tag=nginx response_time;
access_log  /dev/stdout  stream-main;

Note: same helmchart and same version(3.4.3) works for nginx ingress controller (opensource) but not for nginx plus ingress controller.
github-actions[bot] commented 1 month ago

Hi @reddyblokesh thanks for reporting!

Be sure to check out the docs and the Contributing Guidelines while you wait for a human to take a look at this :slightly_smiling_face:

Cheers!

oseoin commented 1 month ago

Hi @reddyblokesh, are you using Ingress or custom resources? I haven't been able to reproduce on 3.4.3, I can see that /var/log/nginx/access.log gets created but it remains empty and logs are correctly sent to stdout. Could you also try running grep access.log /etc/nginx/conf.d/* in case the log configuration is coming from another file? Thanks!

reddyblokesh commented 1 month ago
  1. grep access.log /etc/nginx/conf.d/* access_log /var/log/nginx/access.log main; access_log on;

  2. grep stdout /etc/nginx/nginx.conf access_log /dev/stdout main; access_log /dev/stdout stream-main;

    1. /var/log/nginx/access.log gets created but doesnt create symbolic link to /dev/stdout : ls -la /var/log/nginx/ : total 36 drwxrwxr-x. 1 nginx root 24 Feb 19 13:41 . drwxr-xr-x. 1 root root 19 Feb 19 13:41 .. -rw-rw----. 1 nginx root 34935 May 17 10:38 access.log -rw-rw----. 1 nginx root 0 Feb 19 13:41 error.log
reddyblokesh commented 1 month ago

to reproduce this we tried to upgrade nginx ingress controller to nginx plus in another namespace running a different app in backend and we faced the same issue even there. so it looks like a bug ? can you please confirm or should we build a custom image but adding a symlink similar to what we have in docker-mn ?

oseoin commented 1 month ago

@reddyblokesh just to understand your use-case are you using Ingress or VirtualServer (custom resources), and are you using the snippets feature? If you are not using snippets to add access_log /var/log/nginx/access.log main; access_log on; then it could be a bug with our Plus templates.

We currently do not manually add symlinks, but they are added upstream in the OSS container that we build from, so we can investigate adding the links to our Plus images.

reddyblokesh commented 1 month ago

config: entries: ingress-template: | access_log /var/log/nginx/access.log main;

oseoin commented 1 month ago

@reddyblokesh to clarify:

For now, I recommend you either build a custom image with the symlink, or change your example above to use /dev/stdout instead of /var/log/nginx/access.log. We will investigate adding the symlinks for a future release to better align the OSS and Plus images.

Is there a reason that you use /var/log/nginx/access.log instead of /dev/stdout? Knowing the use-case will help prioritise the work to add the symlinks.

pdabelf5 commented 1 month ago

@jasonwilliams14 fyi