Silly Kubectl Trick #4: Getting at Those Logs
The logs command has two flags that are most helpful for watching live log streams: the --tail flag, and =10
Join the DZone community and get the full member experience.Join For Free
UNIX/Linux system administrators the world over regularly use log files to get to the bottom of outages and malfunctions. An indispensable tool in that regard is
tail(1), particularly its follow mode flag (
-f). When we're in a Kubernetes world, we'd love to use something similar.
We're in luck.
logs command has two flags that are most helpful for watching live log streams: the aptly-named
This one-two combo is super helpful for tracing ongoing issues on a running system. Limiting the context with
=10 prevents us from fixating on old problems that may have since been resolved. Streaming the log as it happens gives us the opportunity to poke and prod at the system, seeing new log entries appear as we do things in the application or service under scrutiny.
Pro Tip: While tailing, you can hit <Enter> a few times to insert lots of blank lines, thus demarcating the stretches of time between trying things in the front-end.
When Pods Crash
What I really need is the end of the log buffer from the failed / crash instance:
With that information in hand, I can continue my diagnostic efforts and hopefully resolve this early morning nuisance.
Published at DZone with permission of . See the original article here.
Opinions expressed by DZone contributors are their own.