Can't view logs in python pod/container

3,793 views
Skip to first unread message

David Rosenstrauch

unread,
Aug 9, 2017, 12:30:30 PM8/9/17
to kubernet...@googlegroups.com
I'm running a python process (django server) in a pod, which writes its
output to stdout, but attempting to view the logs with "kubctl logs"
shows nothing.

I'm similarly unable to view the logs when I run it as a standalone
docker process (i.e., using "docker logs") - unless I run the docker
container using "-dt", at which point I can see the logs just fine using
"docker logs".

The problems, here though, are:

1) kubectl doesn't have a flag combo of -dt that I can use to launch the
container.
2) If I try to use kubectl to launch using just "-t", it forces me to
use "-i" as well - which then puts me into interactive mode, which is
not what I want.
3) It seems like I'm doing something wrong here - i.e., I shouldn't need
to be jumping through all these hoops altogether to be getting log
output.

Can anyone please advise what's the correct way to handle this?

Thanks,

DR

Brandon Philips

unread,
Aug 10, 2017, 1:16:15 PM8/10/17
to kubernet...@googlegroups.com
Hello David-

Can you share the code to your app? Something about the app requires a TTY to print out logs.

Alternatively, add `tty: True` to the PodSpec https://kubernetes.io/docs/api-reference/v1.7/#podspec-v1-core

Brandon

--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

David Rosenstrauch

unread,
Aug 10, 2017, 2:11:01 PM8/10/17
to kubernet...@googlegroups.com
The Dockerfile is pretty straightforward:

FROM ubuntu:16.04
RUN apt-get update && apt-get install -y --no-install-recommends
python3-django sqlite3 && rm -rf /var/lib/apt/lists/*
WORKDIR django-apps
ADD challenge1.tar.gz .
WORKDIR challenge1
EXPOSE 8080
ENTRYPOINT python3 -u manage.py runserver 0.0.0.0:8080

And then I launch it on k8s like so:

kubectl run custom-django-app
--image="<private-registry>:5000/custom-django-app"
kubectl expose deployments custom-django-app --port 8080 --type NodePort

Any idea where I'm going wrong?

Thanks,

DR

Brandon Philips

unread,
Aug 10, 2017, 4:44:01 PM8/10/17
to kubernet...@googlegroups.com
What you are doing is fine. Just do kubectl edit deployment  custom-django-app and add tty: true to the podspec. I bet it will start working.

David Rosenstrauch

unread,
Aug 10, 2017, 4:52:32 PM8/10/17
to kubernet...@googlegroups.com
Yep, that did the trick!

Thanks,

DR

On 2017-08-10 4:43 pm, Brandon Philips wrote:
> What you are doing is fine. Just do kubectl edit deployment
> custom-django-app and add tty: true to the podspec. I bet it will
> start working.
>
> On Thu, Aug 10, 2017 at 11:10 AM David Rosenstrauch
> <dar...@darose.net> wrote:
>
>> The Dockerfile is pretty straightforward:
>>
>> FROM ubuntu:16.04
>> RUN apt-get update && apt-get install -y --no-install-recommends
>> python3-django sqlite3 && rm -rf /var/lib/apt/lists/*
>> WORKDIR django-apps
>> ADD challenge1.tar.gz .
>> WORKDIR challenge1
>> EXPOSE 8080
>> ENTRYPOINT python3 -u manage.py runserver 0.0.0.0:8080 [1]
> Links:
> ------
> [1] http://0.0.0.0:8080

Brandon Philips

unread,
Aug 10, 2017, 4:53:27 PM8/10/17
to kubernet...@googlegroups.com
Great! I would argue your application isn't behaving properly and there is some code that expects a TTY that should be fixed.
Reply all
Reply to author
Forward
0 new messages