当前位置:网站首页>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
边栏推荐
- Ebpf cilium practice (2) - underlying network observability
- Famine cloud service management script
- ZCMU--1396: 队列问题(2)
- 一种适用于应用频繁测试下快速查看Pod的日志的方法(grep awk xargs kuberctl)
- Register of assembly language by Wang Shuang
- 拓维信息使用 Rainbond 的云原生落地实践
- CTF-WEB shrine模板注入nmap的基本使用
- Rainbow combines neuvector to practice container safety management
- Lua programming learning notes
- 如何理解分布式架构和微服务架构呢
猜你喜欢
Leetcode medium question my schedule I
Application of slip ring of shipborne radar antenna
2-3查找树
buureservewp(2)
【雅思口语】安娜口语学习记录 Part2
Wang Zijian: is the NFT of Tencent magic core worth buying?
One click installation of highly available Nacos clusters in rainbow
漏洞复现-Fastjson 反序列化
[IELTS speaking] Anna's oral learning records part2
Make LIVELINK's initial pose consistent with that of the mobile capture actor
随机推荐
解读创客思维与数学课程的实际运用
利用 Helm 在各类 Kubernetes 中安装 Rainbond
Application of slip ring of shipborne radar antenna
eBPF Cilium实战(2) - 底层网络可观测性
XCiT学习笔记
Function extension, attribute extension and non empty type extension in kotlin
Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
Le système mes est un choix nécessaire pour la production de l'entreprise
Opencv learning note 4 - expansion / corrosion / open operation / close operation
打通法律服务群众“最后一公里”,方正璞华劳动人事法律自助咨询服务平台频获“点赞”
OpenVSCode云端IDE加入Rainbond一体化开发体系
buureservewp(2)
Leetcode 187 Repeated DNA sequence (2022.07.06)
使用BiSeNet实现自己的数据集
Give full play to the wide practicality of maker education space
rsync远程同步
One click deployment of highly available emqx clusters in rainbow
Caractéristiques de bisenet
Opencv learning notes 1 -- several methods of reading images
Pytoch (VI) -- model tuning tricks