您现在的位置是:热点 >>正文
两款超好用的 Kubernetes 实时日志查看工具
热点1074人已围观
简介...
通常情况下,Kubernetes 环境下的应用日志都需要通过日志系统来进行收集,比如:Filebeat + ElasticSearch + Kibana 的组合来实现。虽然这一组合的功能相当强大,但是在一些比较简陋的测试集群中,或者不具备浏览器条件的自动化/控制台环境下,自动合并多个 Pod 中的日志进行集中的查看,对处理问题和调试故障还是很有大帮助的。
今天,我们就给大家介绍两款超好用的多容器实时日志查看工具 Stern 和 K两款ubetail。
Stern
Kubectl 本身的 Log 命令是不支持同时查看多个 Pod 容器中的日志,Stern 很好的解决了这个问题, 它除了可以同时 tail 多个容器的日志之外, 还支持以下一些强大的功能:
允许使用正则表达式来选择需要 tail 的 PodName 自定义不同 Pod 的日志输出的颜色 自动添加符合规则的新创建 Pod 并进行 tail ....
项目地址:https://github.com/wercker/stern
安装 Stern
S超好tern 使用 Go 语言开发,安装非常简单,开箱即用。你只需下载对应平台相关的二进制预编译安装包,就可以使用了。
以 Linux 平台为例:
$ wget https://github.com/wercker/stern/releases/download/1.11.0/stern_linux_amd64 $ chmod +x stern_linux_amd64&用的nbsp;$ 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&ubnbsp;.
实时查看指定时间范围内容器的日志,下面的例子表示是 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
如果你使用te的是 macOS,也可以直接 Homebrew 进行安装。
$ brew tap johanhaleby/kubetail && brew install kubetail
Kubetail 还支持各种 SHELL 管理框架,比如:Oh-my-zsh、Antigen 等,具体安装方法可参考「官方安装文档」。
使用 Kubetail
Kus betail 使用也是非常简单的,基本语法如下:
$ kubetail [-h] [-c] [-n] [-t] [-l] [-d] [-p] [-s] [-b] [-k] [-v] [-r] [-i]
一些常用参数的解释:
-c:指定多容器&n实时bsp;Pod 中的容器名称 -t:指定 Kubeconfig 文件中的 Context -l:标签过滤器,使用 -l 参数之后,会忽略 Pod 名称 -n:指定命名空间 -s:指定返回一个相对时间之后的日志,例如 5s,2m 或者 3h,缺省是 10s&nb日志sp;-b:是否使用 line-buffered,缺省为 false -k:指定输出内容的具体着色部分,pod:只给 pod 名称上色,line:整行上色(缺省),false:不上色
一些使用实例:
$ 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 ser工具vice=my-service $ kubetail --selector service=my-service --since 10m $ kubetail --tail 1
至此,两种超实用的多容器实时日志查看工具就介绍完了。如果你还有更好的类似工具推荐,欢迎留言讨论哟!
参考文档
https://w两款ww.google.com
https://zhuanlan.zhihu.com/p/60987559
https://blog.fleeto.us/post/introducing-kubetail/
Tags:
相关文章
标签: 贝壳 贝好家 AI助手 家装家居
热点云梦级11月10日云梦级消息,11月10日,贝壳(NYSE:BEKE;HKEX:2423)发布三季度业绩公告。第三季度,贝壳总交易额(GTV)达7367亿元(人民币,下同),净收入同比增长2.1%至2...
【热点】
阅读更多标签: 长安汽车 长安启源Q07 阿维塔06 深蓝S09
热点云梦级4月14日云梦级消息,长安汽车于 4 月 10 日晚间对外披露 2025 年年度报告,数据显示公司实现营业收入 1640 亿元,同比增长 2.67%;归属于上市公司股东的净利润为 40.75 亿...
【热点】
阅读更多标签: 小米YU7GT 三星电子 英伟达 雷军
热点Hello,大家早上好,又是元气满满的一天,先来浏览新鲜的早报吧~ 【雷军称小米YU7 GT有点小贵】 小米 YU7 GT 即将发布,雷军称其为时代精英打造。新车搭载新一代超级电机 V8s EVO,最...
【热点】
阅读更多
热门文章
最新文章
友情链接
- 标签: 康师傅
- https://www.voices.com/talents/search?keywords=歌外推【tg:seogoogle987】,am4
- https://www.qylaws.com/search/歌外推【tg:seogoogle987】,JWA
- https://www.qwant.com/?q=歌外推【tg:seogoogle987】,itq
- https://www.sogou.com/web?query=歌外推【tg:seogoogle987】,eex
- https://www.parl.ca/legisinfo/fr/projets-de-loi?parlsession=all&view=list&keywords=歌外推【tg:seogoogle987】,bEQ
- https://www.roberthalf.com/us/en/jobs/all/歌外推【tg:seogoogle987】76X
- https://www.hanbat.ac.kr/search/front/Search.jsp?qt=歌外推【tg:seogoogle987】cta
- https://www.quarterjacksurgery.co.uk/?AT=3rBy&s=歌外推【tg:seogoogle987】,6sg
- https://www.unclefossil.com/search/歌外推【tg:seogoogle987】,xDw
- https://www.teamlab.art/it/?submit=歌外推【tg:seogoogle987】,etL
- https://www.mexperience.com/?T=1686132112324&s=歌外推【tg:seogoogle987】,n8F
- https://www.temu.com/search_result.html?search_key=歌外推【tg:seogoogle987】03G
- https://www.teamlab.art/pt/?submit=歌外推【tg:seogoogle987】,1Zz
- https://wwwcp.umes.edu/search/歌外推【tg:seogoogle987】,7dj
- https://www.nslcleaders.org/?s=歌外推【tg:seogoogle987】,jpo
- https://www.spicebar.de/catalogsearch/result/?q=歌外推【tg:seogoogle987】,134
- https://www.kaskus.co.id/search?q=歌外推【tg:seogoogle987】,Thh
- https://www.mi.com/search?keyword=歌外推【tg:seogoogle987】,CEI
- https://www.rookwinkel.nl/catalogsearch/result/index/?q=歌外推【tg:seogoogle987】,wZD
- https://www.sonepar.ch/fr/search?q=歌外推【tg:seogoogle987】,MTP
- https://www.sic-info.org/vi/?s=歌外推【tg:seogoogle987】,fww
- https://yscc1986.net/search/歌外推【tg:seogoogle987】4qt
- https://www.kawainter.com/catalogsearch/result/?q=歌外推【tg:seogoogle987】,1em
- https://www.signingsavvy.com/sentence/歌外推【tg:seogoogle987】,Hu0
- https://www.partilerdunyasi.com/index.php?route=product/search&tag=歌外推【tg:seogoogle987】,nAP
- https://www.metalmensales.com/?action=QUERY&s=歌外推【tg:seogoogle987】,Ag7
- https://www.nissin.com/jp/search/?cat=105&q=歌外推【tg:seogoogle987】,76A
- https://wydden.com/?ID=r8w9WMSKWkOcmiaFWaUv0dzMdqZWfKtF&s=歌外推【tg:seogoogle987】,9ul
- https://www.pickett.co.uk/collections/vendors?q=歌外推【tg:seogoogle987】,n1F
- https://www.smics.com/tc/site/search?token=歌外推【tg:seogoogle987】,iJ1
- https://www.abbreviations.com/歌外推【tg:seogoogle987】Vzg
- https://www.kuaikanmanhua.com/sou/歌外推【tg:seogoogle987】,ien
- https://www.ncetm.org.uk/search?action=CHECK&q=歌外推【tg:seogoogle987】,xjP
- https://www.remit.co.jp/vi/?s=歌外推【tg:seogoogle987】,pfA
- https://search.danawa.com/dsearch.php?query=歌外推【tg:seogoogle987】26w
- https://www.pixiv.net/tags/歌外推【tg:seogoogle987】,tp9
- https://www.nbm.org/?action=QUERY&s=歌外推【tg:seogoogle987】,uEz
- https://www.wuv.edu/?s=歌外推【tg:seogoogle987】,crO
- https://www.trockenmittel.ch/catalogsearch/result/?iC=ZM3&q=歌外推【tg:seogoogle987】,BTi
- https://www.oprny.com/search.php?search_query=歌外推【tg:seogoogle987】,1YM
- https://www.openstreetmap.org/search?query=歌外推【tg:seogoogle987】,IMk
- https://blvdseafood.com/?s=歌外推【tg:seogoogle987】TE8
- https://www.londontheatredirect.com/search/歌外推【tg:seogoogle987】,x6q
- https://www.mesec.cz/vyhledavani/?qs=歌外推【tg:seogoogle987】,3YX
- https://www.tmtpost.com/search?q=歌外推【tg:seogoogle987】,0gb
- https://www.jusoen.com/addreng.asp?p1=歌外推【tg:seogoogle987】Bs9
- https://www.lgnewsroom.com/search/歌外推【tg:seogoogle987】,zCj
- https://www.olx.ba/pretraga?trazilica=歌外推【tg:seogoogle987】,d4z
- https://www.simcoemuskokahealth.org/SearchResults.aspx?SearchQuery=歌外推【tg:seogoogle987】,Byu
- https://www.schenckprocess.com/search?q=歌外推【tg:seogoogle987】,srH