- Kubernetes for Developers
- Joseph Heck
- 152字
- 2025-02-25 15:31:25
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 some output akin to the following:
* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 996-805-904