当前位置:网站首页>一种适用于应用频繁测试下快速查看Pod的日志的方法(grep awk xargs kuberctl)
一种适用于应用频繁测试下快速查看Pod的日志的方法(grep awk xargs kuberctl)
2022-07-07 05:25:00 【码二哥】
在k8s里频繁的进行应用软件测试时,需要频繁的查看日志
此时,需要频繁的获取pod的名称,
很麻烦,如何快速查看日志呢?
| 问题描述 |
如何快速查看flannel相关的某个pod日志呢?
| 快速查看日志方式1、直接命令行方式查看 |
通过grep 、awk、xargs 结合 获取 指定pod的名称,查看日志

参考命令,如下
kubectl get pod -A | grep "kube-flannel-ds" | awk '{print $1" "$2}' | head -1 |xargs kubectl logs -f -n
head -1,表示获取满足要求的第1行内容
xargs用来获取数据
| 快速查看日志方式2、Makefile方式 |
将上面的命令,放到Makefile里
如下
文件Makefile的内容:
log:
kubectl get pod -A | grep "kube-flannel-ds" | awk '{print $$1" "$$2}' | head -1 |xargs kubectl logs -f -n

在Makefile文件存在的路径下,
执行
make log
就相当于查看日志了
| 快速查看日志方式3、脚本方式 |
创建一个查看日志脚本,如下
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
查看日志时,直接
./getlog.sh
已发表专栏的入口,欢迎订阅,共同进步
0 grpc-go、protobuf、multus-cni 技术专栏 总入口
边栏推荐
- Rainbow 5.7.1 supports docking with multiple public clouds and clusters for abnormal alarms
- Complex network modeling (I)
- Kotlin combines flatmap for filtering and zip merge operators
- [quick start of Digital IC Verification] 12. Introduction to SystemVerilog testbench (svtb)
- [quick start of Digital IC Verification] 14. Basic syntax of SystemVerilog learning 1 (array, queue, structure, enumeration, string... Including practical exercises)
- 利用 Helm 在各类 Kubernetes 中安装 Rainbond
- Zcmu--1396: queue problem (2)
- Four items that should be included in the management system of integral mall
- Using nocalhost to develop microservice application on rainbow
- Blob object introduction
猜你喜欢

Easy to understand SSO

Application of slip ring of shipborne radar antenna

Coquette data completes the cloud native transformation through rainbow to realize offline continuous delivery to customers

opencv学习笔记五——梯度计算/边缘检测

解读创客思维与数学课程的实际运用

opencv学习笔记四——膨胀/腐蚀/开运算/闭运算

Interpreting the practical application of maker thinking and mathematics curriculum

Battery and motor technology have received great attention, but electric control technology is rarely mentioned?

Register of assembly language by Wang Shuang

利用 Helm 在各类 Kubernetes 中安装 Rainbond
随机推荐
One click deployment of highly available emqx clusters in rainbow
The reified keyword in kotlin is used for generics
eBPF Cilium实战(2) - 底层网络可观测性
利用 Helm 在各类 Kubernetes 中安装 Rainbond
rsync远程同步
[quick start of Digital IC Verification] 10. Verilog RTL design must know FIFO
Splunk中single value视图使用将数值替换为文字
Zcmu--1492: problem d (C language)
Zcmu--1396: queue problem (2)
漏洞复现-Fastjson 反序列化
单元测试报告成功率低
Use of JMeter
漏洞复现-easy_tornado
IP-guard助力能源企业完善终端防泄密措施,保护机密资料安全
Explore creativity in steam art design
Learn how to compile basic components of rainbow from the source code
The simple problem of leetcode is to judge whether the number count of a number is equal to the value of the number
Open3D ISS关键点
Rainbow combines neuvector to practice container safety management
解析机器人科技发展观对社会研究论