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.

The logs command has two flags that are most helpful for watching live log streams: the aptly-named --tail flag:

Shell

1

kubectl logs my-pod-name --tail=10

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 a few times to insert lots of blank lines, thus demarcating the stretches of time between trying things in the front-end.

#open source #tutorial #devops #kubernetes #containers #open-source #k8s #kubectl

Silly Kubectl Trick #4: Getting at Those Logs
1.10 GEEK