您现在的位置是:热点 >>正文
两款超好用的 Kubernetes 实时日志查看工具
热点9777人已围观
简介...
通常情况下,Kubernetes 环境下的应用日志都需要通过日志系统来进行收集,比如:Filebeat + ElasticSearch + Kibana 的组合来实现。虽然这一组合的功能相当强大,但是在一些比较简陋的测试集群中,或者不具备浏览器条件的自动化/控制台环境下,自动合并多个 Pod 中的日志进行集中的查看,对处理问题和调试故障还是很有大帮助的。
今天,我们就给大家介绍两款超好用的多容器实时日志查看工具 Stern 和 K两款ubetail。
Stern
Kubectl 本身的 Log 命令是不支持同时查看多个 Pod 容器中的日志,Stern 很好的解决了这个问题, 它除了可以同时 tail 多个容器的日志之外, 还支持以下一些强大的功能:
允许使用正则表达式来选择需要 tail 的 PodName 自定义不同 Pod 的日志输出的颜色 自动添加符合规则的新创建 Pod 并进行 tail ....
项目地址:https://github.com/wercker/stern
安装 St超好ern
Stern 使用 Go 语言开发,安装非常简单,开箱即用。你只需下载对应平台相关的二进制预编译安装包,就可以使用了。
以 Linux 平台为例:
$ wget https://github.com/wercker/stern/releases/download/1.11.0/stern_linux_amd64 $ chmod +x stern_linux_amd6用的4 $ mv stern_linux_amd64 /usr/local/bin
如果你使用的是 macOS,可以直接 Homebrew 进行安装。
$ brew install stern
使用 Stern
Stern 支持的功能很多,用法也很丰富。下面我们来看几个比较常用的例子:
实时查看当前 Namespace 中所有 Pod 中所有容器的日志
$ K stern .
实时查看 Pod 中指定容器的日志
$ stern envvars --container gateway
实时查看指定命名空间中除指定容器外的所有容器的日志
$ stern -n staging --exclude-container istio-proxy&nbubsp;.
实时查看指定时间范围内容器的日志,下面的例子表示是 15 分钟内
$ stern auth -t --since 15m
实时查看指定命名空间中容器的日志
$ stern kubernetes-dashboard --namespace kube-system
实时查看所有命名空间中符合指er定标签容器的日志
$ stern --all-namespaces -l run=nginx
更多用法,可参考「官方文档」。
Kubetail
Kubetail 是一个 Shell 脚本,它可以将多个 Pod 的日志合并到一起,并支持彩色输出。
项目地址:https://github.com/johanhaleby/kubetail
安装 Kubetail
由于 Kubetail 只是一ne个 Shell 脚本,直接下载后便可使用。
$ wget https://raw.githubusercontent.com/johanhaleby/kubetail/master/kubetail $ chmod +x kubetail $ cp kubetail /usr/local/bin
如果你使用的是 matecOS,也可以直接 Homebrew 进行安装。
$ brew tap johanhaleby/kubetail && brew install kubetail
Kubetail 还支持各种 SHELL 管理框架,比如:Oh-my-zsh、Antigen 等,具体安装方法可参考「官方安装文档」。
使用 Kubetail
Kubetail 使s 用也是非常简单的,基本语法如下:
$ kubetail [-h] [-c] [-n] [-t] [-l] [-d] [-p] [-s] [-b] [-k] [-v] [-r] [-i]
一些常用参数的解释:
-c:指定多容器 Pod实时 中的容器名称 -t:指定 Kubeconfig 文件中的 Context -l:标签过滤器,使用 -l 参数之后,会忽略 Pod 名称 -n:指定命名空间 -s:指定返回一个相对时间之后的日志,例如 5s,2m 或者 3h,缺省是 10s -b日志:是否使用 line-buffered,缺省为 false -k:指定输出内容的具体着色部分,pod:只给 pod 名称上色,line:整行上色(缺省),false:不上色
一些使用实例:
$ kubetail my-pod-v1 $ kubetail my-pod-v1 -c my-co查看ntainer $ kubetail my-pod-v1 -t int1-context -c my-container $ kubetail '(service|consumer|thing)' -e regex $ kubetail -l serv工具ice=my-service $ kubetail --selector service=my-service --since 10m $ kubetail --tail 1
至此,两种超实用的多容器实时日志查看工具就介绍完了。如果你还有更好的类似工具推荐,欢迎留言讨论哟!
参考文档
https://www.g两款oogle.com
https://zhuanlan.zhihu.com/p/60987559
https://blog.fleeto.us/post/introducing-kubetail/
Tags:
相关文章
云计算开发:Python内置函数-__import__()函数详解
热点描述 __import__() 函数用于动态加载类和函数 。 如果一个模块经常变化就可以使用 __import__() 来动态载入。 语法 以下是 __import__ 方法的语法: __import...
【热点】
阅读更多OpenAI再加速:奥尔特曼预告GPT-6即将到来,主打个性化与记忆功能
热点尽管GPT-5刚刚问世,但OpenAI首席执行官萨姆·奥尔特曼已在上周的媒体活动中透露了公司未来的雄心。他明确表示,GPT-6已经在开发中,并且其发布间隔将比GPT-4和GPT-5之间更短。奥尔特曼强...
【热点】
阅读更多5个用于培养数字工作场所的优秀大数据工具
热点业务的未来很大程度上取决于大数据的发展。技术领域为企业带来的最大进步之一就是利用人工智能,机器学习和其他大数据工具创建数字工作场所。 这种新的工作环境专门在虚拟环境中运行。企业所有者使用数字工作场所来...
【热点】
阅读更多
热门文章
最新文章
友情链接
- 标签: 康师傅
- https://www.remit.co.jp/vi/?s=谷歌留痕软件【tg:seogoogle987】,SrQ
- https://www.sic-info.org/vi/?s=谷歌留痕软件【tg:seogoogle987】,i7J
- https://www.wellbees.com/index.php/catalogsearch/result/index/?q=谷歌留痕软件【tg:seogoogle987】,JXM
- https://www.temu.com/search_result.html?search_key=谷歌留痕软件【tg:seogoogle987】o6k
- https://www.tumblr.com/tagged/谷歌留痕软件【tg:seogoogle987】,xMr
- https://www.londontheatredirect.com/search/谷歌留痕软件【tg:seogoogle987】,p0H
- https://www.localfootdoc.com/?s=谷歌留痕软件【tg:seogoogle987】,UCt
- https://www.remit.co.jp/ne/?s=谷歌留痕软件【tg:seogoogle987】,PSb
- https://www.roberthalf.com/us/en/jobs/all/谷歌留痕软件【tg:seogoogle987】CJv
- https://www.lauben.com/en/?action=SEARCH&s=谷歌留痕软件【tg:seogoogle987】,g19
- https://www.flickr.com/photos/tags/谷歌留痕软件【tg:seogoogle987】Qaj
- https://www.kuaikanmanhua.com/sou/谷歌留痕软件【tg:seogoogle987】,3SO
- https://www.kyuhoshi.com/?s=谷歌留痕软件【tg:seogoogle987】,Ns0
- https://www.lgnewsroom.com/search/谷歌留痕软件【tg:seogoogle987】,ccB
- https://www.safetv.go.kr/base/search/view?searchWord=谷歌留痕软件【tg:seogoogle987】2GS
- https://www.universal-music.co.jp/search/?q=谷歌留痕软件【tg:seogoogle987】,pDW
- https://www.tcv.org.uk/search/谷歌留痕软件【tg:seogoogle987】,huo
- https://www.supersauna.de/catalogsearch/result/?q=谷歌留痕软件【tg:seogoogle987】,Hp5
- https://www.signingsavvy.com/sentence/谷歌留痕软件【tg:seogoogle987】,tHf
- https://www.jusoen.com/addreng.asp?p1=谷歌留痕软件【tg:seogoogle987】Xu1
- https://www.springfieldlibrary.org/?s=谷歌留痕软件【tg:seogoogle987】,gRM
- https://m.shoppinghow.kakao.com/m/search/q/谷歌留痕软件【tg:seogoogle987】6fX
- https://www.polar-tech.com/?action=QUERY&s=谷歌留痕软件【tg:seogoogle987】,5mP
- https://www.mynextmove.org/find/search?s=谷歌留痕软件【tg:seogoogle987】,V2Z
- https://www.televes.com/es/catalogsearch/result/?q=谷歌留痕软件【tg:seogoogle987】,l2t
- https://www.zutari.com/search/谷歌留痕软件【tg:seogoogle987】,IBy
- https://www.scivee.tv/?s=谷歌留痕软件【tg:seogoogle987】,jBF
- https://www.rockngem.com/?action=CHECK&s=谷歌留痕软件【tg:seogoogle987】,JNe
- https://www.smarty.net/search?q=谷歌留痕软件【tg:seogoogle987】,qcM
- https://www.welshmountainzoo.org/shop/index.php?routeproduct/search&tag=谷歌留痕软件【tg:seogoogle987】,olJ
- https://nicolazzi.it/en/?s=谷歌留痕软件【tg:seogoogle987】,j7s
- https://www.teamlab.art/fr/?submit=谷歌留痕软件【tg:seogoogle987】,OvI
- https://dict.naver.com/dict.search?dicQuery&query=谷歌留痕软件【tg:seogoogle987】3O6
- https://www.kaskus.co.id/search?q=谷歌留痕软件【tg:seogoogle987】,7b7
- https://www.roberthalf.com/us/en/jobs/all/谷歌留痕软件【tg:seogoogle987】Qc6
- https://www.stormberg.com/no/search?q=谷歌留痕软件【tg:seogoogle987】,1dN
- https://www.symatoys.com/search.html?ID=UyMD6aO58bPrJvQAB1I0N69KzJBZeNPC&keyword=谷歌留痕软件【tg:seogoogle987】,EIl
- https://www.kelsa.co.uk/catalogsearch/result/index/?T=1686132119291&q=谷歌留痕软件【tg:seogoogle987】,pNs
- https://www.silentiumpc.com/en/search/谷歌留痕软件【tg:seogoogle987】,XVp
- https://www.whiterock2008.com.tw/search?q=谷歌留痕软件【tg:seogoogle987】,3M1
- https://www.ushmm.org/search/results/?ID=8s0587Oi8UTv74zPPM4fuhwjNpe2hsEE&q=谷歌留痕软件【tg:seogoogle987】,7LQ
- https://www.kissthekangaroo.com.au/index.php?route=product/search&tag=谷歌留痕软件【tg:seogoogle987】,mhN
- https://www.shacknews.com/editorial-search?q=谷歌留痕软件【tg:seogoogle987】,Kzy
- https://www.valuecolleges.com/?action=QUERY&s=谷歌留痕软件【tg:seogoogle987】,7qT
- https://www.simcoemuskokahealth.org/SearchResults.aspx?SearchQuery=谷歌留痕软件【tg:seogoogle987】,JYx
- https://www.uckfieldtc.gov.uk/?s=谷歌留痕软件【tg:seogoogle987】,XX2
- https://www.remit.co.jp/zh/?s=谷歌留痕软件【tg:seogoogle987】,j3g
- https://www.nctsn.org/search?cat=191&query=谷歌留痕软件【tg:seogoogle987】,TMF
- https://www.navylookout.com/?ID=nSBR6Ivdu6lZg1yr2SDs30Lo5sTs76yJ&s=谷歌留痕软件【tg:seogoogle987】,tLt
- https://www.lssystems.co.uk/search?page=0&per_page=24&term=谷歌留痕软件【tg:seogoogle987】,BrK