当前位置:网站首页>A method for quickly viewing pod logs under frequent tests (grep awk xargs kuberctl)
A method for quickly viewing pod logs under frequent tests (grep awk xargs kuberctl)
2022-07-07 08:27:00 【Code two brother】
stay k8s During frequent application software testing , You need to check the log frequently
here , Need frequent access pod The name of ,
so much trouble , How to quickly view logs ?
| Problem description |
How to quickly view flannel Related one pod The Journal ?
| How to quickly view logs 1、 View directly from the command line |
adopt grep 、awk、xargs combination obtain Appoint pod The name of , Check the log

Refer to the order , as follows
kubectl get pod -A | grep "kube-flannel-ds" | awk '{print $1" "$2}' | head -1 |xargs kubectl logs -f -n
head -1, It means to obtain the second 1 Row content
xargs Used to get data
| How to quickly view logs 2、Makefile The way |
Put the above command , Put it in Makefile in
as follows
file Makefile The content of :
log:
kubectl get pod -A | grep "kube-flannel-ds" | awk '{print $$1" "$$2}' | head -1 |xargs kubectl logs -f -n

stay Makefile Under the path where the file exists ,
perform
make log
It's equivalent to checking the log
| How to quickly view logs 3、 Script mode |
Create a script to view logs , as follows
vim getlog.sh
#!/bin/sh
kubectl get pod -A | grep "kube-flannel-ds" | awk '{print $1" "$2}' | head -1 |xargs kubectl logs -f -n
chmod +x getlog.sh
When checking the log , direct
./getlog.sh
Entry to published columns , Welcome to subscribe to , Common progress
0 grpc-go、protobuf、multus-cni Technical column The main entrance
1 grpc-go Source code analysis and actual combat List of articles
2 Protobuf Introduction and actual combat Graphic column List of articles
3 multus-cni List of articles (k8s Multi network implementation scheme )
4 grpc、oauth2、openssl、 Two-way authentication 、 One way authentication and other column contents
边栏推荐
猜你喜欢

Rsync remote synchronization

Pvtv2--pyramid vision transformer V2 learning notes

Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster

Lua programming learning notes

Low success rate of unit test report

AVL平衡二叉搜索树

Golang 编译约束/条件编译 ( // +build <tags> )
![[untitled]](/img/b5/348b1d8b5d34cf10e715522b9871f2.png)
[untitled]

机器人教育在动手实践中的真理

Register of assembly language by Wang Shuang
随机推荐
【雅思口语】安娜口语学习记录 Part3
Application of slip ring of shipborne radar antenna
Learn how to compile basic components of rainbow from the source code
rsync远程同步
使用 Nocalhost 开发 Rainbond 上的微服务应用
打通法律服务群众“最后一公里”,方正璞华劳动人事法律自助咨询服务平台频获“点赞”
[untitled]
XCiT学习笔记
ZCMU--1396: 队列问题(2)
Opencv learning notes II - basic image operations
[untitled]
Lua programming learning notes
Practice of implementing cloud native Devops based on rainbow library app
The field value in Splunk subquery fuzzy matching CSV is*
发挥创客教育空间的广泛实用性
BiSeNet的特點
The largest 3 same digits in the string of leetcode simple question
opencv学习笔记五——梯度计算/边缘检测
Interview questions (CAS)
Interface as a parameter (interface callback)