I am using Kubernetes to run a python script as a cron job. The issue is that I am not seeing the output of the script (Which can take a while to run) until after the job finishes. I suspect this is due to the logging level (--v option) but I cannot for the life of my find either the documentation for it (it default to --v=0). IF I want to increase the verbosity of what is outputted, does anyone know the value of 'INFO' or 'TRACE' (or what the values are/where they are defined)? Thank for any help in advance.
Edit: has anyone successfully gotten a python file to log to a Kubernetes pod while the pod was running? If so did you use print() or a different logging framework?
According to Kubernetes docs,
If you don't see much useful in the logs, you could try turning on
verbose logging on the Kubernetes component you suspect has a problem
using --v or --vmodule, to at least level 4. See
https://github.com/golang/glog for more details.
Found the root cause. Specifically, found it at Python app does not print anything when running detached in docker . The solution is to set the following environmental variable: PYTHONUNBUFFERED=0 . It was not that the print statement was not being displayed, it was that the print statement was being buffered. Doing the above will solve the issue. Thank you @thisguy17 and @fylie for assisting.