Tailing few lines from huge logs of kubectl logs -f

In a cluster best practices are to gather all logs in a single point through an aggregator and analyze them with a dedicated tool. For that reason in K8S, log command is quite basic.

Anyway kubectl logs -h shows some options useful for you:

# Display only the most recent 20 lines of output in pod nginx
kubectl logs --tail=20 nginx

# Show all logs from pod nginx written in the last hour
kubectl logs --since=1h nginx

Some tools with your requirements (and more) are available on github, some of which are:

  • https://github.com/boz/kail

  • https://github.com/wercker/stern

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)