I have simple python 2.7 program running in container off Kubernetes (AKS) which is printing debug information to standard output
response = requests.post(uri,data=body, headers=headers)
if (response.status_code >= 200 and response.status_code <= 299):
print 'Accepted ' + log_type + ' on ' + rfc1123date
else:
print "Response code: {}".format(response.status_code)
I don't see it with kubectl logs container_name
, output is empty (but I know it is fine because of successful post). I tried to add "-u"
to CMD ["-u","syslog2la.py"]
in Dockerfile, but it didn't help. How to get the python print in 'kubectl logs'?
To resolve it, double check the pod specification and ensure that the repository and image are specified correctly. If this still doesn't work, there may be a network issue preventing access to the container registry. Look in the describe pod text file to obtain the hostname of the Kubernetes node.
What is Kubernetes CrashLoopBackOff? CrashLoopBackOff is a common error that you may have encountered when running your first containers on Kubernetes. This error indicates that a pod failed to start, Kubernetes tried to restart it, and it continued to fail repeatedly.
You can see the logs of a particular container by running the command kubectl logs <container name> .
Add the following to your Dockerfile:
ENV PYTHONUNBUFFERED=0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With