In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is about what the Kubernetes real-time log viewer in linux has. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Stern
The Log command of Kubectl itself does not support viewing logs in multiple Pod containers at the same time. Stern solves this problem very well. In addition to tail logs of multiple containers at the same time, it also supports the following powerful features:
Allows you to use regular expressions to select PodName that requires tail
Customize the color of log output for different Pod
Automatically add a newly created Pod that conforms to the rules and tail
....
Project address: https://github.com/wercker/stern
Install Stern
Stern is developed in the Go language and is very easy to install and can be used out of the box. You only need to download the binary precompiled installation package related to the corresponding platform, and you can use it.
Take the Linux platform as an example:
$wget https://github.com/wercker/stern/releases/download/1.11.0/stern_linux_amd64 $chmod + x stern_linux_amd64 $mv stern_linux_amd64 / usr/local/bin
If you are using macOS, you can install it directly by Homebrew.
$brew install stern
Use Stern
Stern supports a lot of features and uses. Let's take a look at some common examples:
1. View the logs of all containers in all Pod in the current Namespace in real time
$stern.
two。 View the logs of specified containers in Pod in real time
$stern envvars-container gateway
3. View the logs of all containers in the specified namespace except the specified container in real time
$stern-n staging-- exclude-container istio-proxy.
4. View the container log in real time within a specified time range. The following example shows that within 15 minutes
$stern auth-t-since 15m
5. View the log of the container in the specified namespace in real time
$stern kubernetes-dashboard-namespace kube-system
6. View logs in all namespaces that match the specified label container in real time
$stern-- all-namespaces-l run=nginx
For more usage, please refer to the official documentation.
Kubetail
Kubetail is a Shell script that combines logs from multiple Pod and supports color output.
Project address: https://github.com/johanhaleby/kubetail
Install Kubetail
Because Kubetail is just a Shell script, you can download it directly and then use it.
$wget https://raw.githubusercontent.com/johanhaleby/kubetail/master/kubetail $chmod + x kubetail $cp kubetail / usr/local/bin
If you are using macOS, you can also install it directly with Homebrew.
$brew tap johanhaleby/kubetail & & brew install kubetail
Kubetail also supports various SHELL management frameworks, such as Oh-my-zsh, Antigen, etc. For specific installation methods, please refer to the "official installation documentation".
Use Kubetail
Kubetail is also very simple to use, and the basic syntax is as follows:
$kubetail [- h] [- c] [- n] [- t] [- l] [- d] [- p] [- s] [- b] [- k] [- v] [- r] [- I]
Explanation of some commonly used parameters:
-c: specify the container name in the multi-container Pod-t: specify the Context-l: tag filter in the Kubeconfig file. After using the-l parameter, ignore the Pod name-n: specify the namespace-s: specify a log that is after a relative time, such as 5sforce 2m or 3h. Default is 10s-b: whether to use line-buffered, default is false-k: specify the specific shaded part of the output Pod: color only the pod name, line: color the whole line (default), false: no color
Some examples of use:
$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 Thank you for reading! This is the end of this article on "what are the real-time log viewing tools for Kubernetes in linux?" I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.