1 problem

If there is a Deployment cluster and the number of copies is 3, the default kubectl log command does not support the Pod log view.

2 kubetail introduction

Kubetail is a Bash script that functions like kubectl -f logs pod-name, except that it works on multiple pods at the same time and merges logs into a single stream.

3 the installation

MacOS

brew tap johanhaleby/kubetail && brew install kubetail 
Copy the code

4 use

Kubetail is also very simple to use, the basic syntax is as follows:

kubetail <search term> [-h] [-c] [-n] [-t] [-l] [-d] [-p] [-s] [-b] [-k] [-v] [-r] [-i] -- tail multiple Kubernetes pod logs at the same time
Copy the code

4.1 Parameter Description

-t: Kubeconfig file context-l: tag filter. -l: tag filter. -n: tag namespace -s: 10s-b: specifies whether to use line-buffered. The default is false. -k: specifies the specific shaded part of the output. Full line color (default), false: no colorCopy the code

4.2 Example

$ kubetail my-pod-v1  
$ kubetail my-pod-v1 -c my-container  
$ kubetail my-pod-v1 -t int1-context -c my-container  
$ kubetail '(service|consumer|thing)' -e regex  
$ kubetail -l service=my-service  
$ kubetail --selector service=my-service --since 10m  
$ kubetail --tail 1 
Copy the code