当前位置:网站首页>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
边栏推荐
- Qinglong panel - today's headlines
- Pytoch (VI) -- model tuning tricks
- 一文了解如何源码编译Rainbond基础组件
- eBPF Cilium实战(1) - 基于团队的网络隔离
- BiSeNet的特點
- 柯基数据通过Rainbond完成云原生改造,实现离线持续交付客户
- 轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
- Open3d ISS key points
- Openjudge noi 2.1 1752: chicken and rabbit in the same cage
- The largest 3 same digits in the string of leetcode simple question
猜你喜欢

Register of assembly language by Wang Shuang
![[IELTS speaking] Anna's oral learning records part2](/img/c4/ad7ba2394ee7a52b67b643aa45a7ae.png)
[IELTS speaking] Anna's oral learning records part2

Golang 编译约束/条件编译 ( // +build <tags> )

Splunk query CSV lookup table data dynamic query

利用 Helm 在各类 Kubernetes 中安装 Rainbond

The simple problem of leetcode is to judge whether the number count of a number is equal to the value of the number

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

Deit learning notes

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

【雅思口语】安娜口语学习记录 Part2
随机推荐
The reified keyword in kotlin is used for generics
SSM 整合
Famine cloud service management script
Practice of combining rook CEPH and rainbow, a cloud native storage solution
MES系統,是企業生產的必要選擇
MES系统,是企业生产的必要选择
在Rainbond中一键部署高可用 EMQX 集群
Offer harvester: add and sum two long string numbers (classic interview algorithm question)
【Go ~ 0到1 】 第七天 获取时间戳,时间比较,时间格式转换,Sleep与定时器
国标GB28181协议视频平台EasyGBS新增拉流超时配置
Basic use of CTF web shrink template injection nmap
Game attack and defense world reverse
Standard function let and generic extension function in kotlin
Caractéristiques de bisenet
Implement your own dataset using bisenet
Ebpf cilium practice (1) - team based network isolation
探索STEAM艺术设计中的创造力
Golang 编译约束/条件编译 ( // +build <tags> )
iptables 之 state模块(ftp服务练习)
Vulnerability recurrence fastjson deserialization