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 and the context-limiting -n.

kubectl logs my-pod-name --tail -n10

This one-two combo is super helpful for tracing ongoing issues on a running system. Limiting the context with

-n 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.

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

Kubernetes Explained Simply: Getting At Those Logs
1.15 GEEK