当前位置:网站首页>一种适用于应用频繁测试下快速查看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 技术专栏 总入口
边栏推荐
- GFS distributed file system
- 柯基数据通过Rainbond完成云原生改造,实现离线持续交付客户
- 在 Rainbond 中一键安装高可用 Nacos 集群
- The largest 3 same digits in the string of leetcode simple question
- 复杂网络建模(一)
- Kotlin combines flatmap for filtering and zip merge operators
- 单场带货涨粉10万,农村主播竟将男装卖爆单?
- The legend about reading the configuration file under SRC
- Rainbond 5.6 版本发布,增加多种安装方式,优化拓扑图操作体验
- DeiT学习笔记
猜你喜欢

Explore creativity in steam art design

Vulnerability recurrence fastjson deserialization

JS cross browser parsing XML application

Splunk子查询模糊匹配csv中字段值为*

Rainbond结合NeuVector实践容器安全管理

Rainbow combines neuvector to practice container safety management

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

Wang Zijian: is the NFT of Tencent magic core worth buying?

Excel import function of jeesite form page

一文了解如何源码编译Rainbond基础组件
随机推荐
解析创新教育体系中的创客教育
Bayes' law
[untitled]
opencv学习笔记一——读取图像的几种方法
积分商城管理系统中应包含的四大项
Qinglong panel -- Huahua reading
Caractéristiques de bisenet
The simple problem of leetcode is to judge whether the number count of a number is equal to the value of the number
Rainbond 5.7.1 支持对接多家公有云和集群异常报警
饥荒云服管理脚本
Splunk查询csv lookup table数据动态查询
Analyzing the influence of robot science and technology development concept on Social Research
Xcit learning notes
opencv学习笔记四——膨胀/腐蚀/开运算/闭运算
Ebpf cilium practice (1) - team based network isolation
MES系統,是企業生產的必要選擇
使用BiSeNet实现自己的数据集
Le système mes est un choix nécessaire pour la production de l'entreprise
Rainbow version 5.6 was released, adding a variety of installation methods and optimizing the topology operation experience
Complex network modeling (I)