Getting logs from your application

There are more ways to interact with your code running in the container, which we'll cover in a future chapter. If the code you run does not listen on a TCP socket to provide HTTP traffic, or something equivalent, then you generally want to see the output that your code created to know that it's running.

Containers are specifically set up to capture any output to STDOUT and STDERR from the executable you've specified and capture that into logs, which can be retrieved with another kubectl command: kubectl logs. Like the proxy and port-forward commands, this command needs to know the name of the Pod you want to interact with.

Run the following command:

kubectl logs flask-1599974757-b68pw

And you should see ...

Get Kubernetes for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.