当前位置:网站首页>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远程同步
- Improve the delivery efficiency of enterprise products (1) -- one click installation and upgrade of enterprise applications
- [quick start of Digital IC Verification] 14. Basic syntax of SystemVerilog learning 1 (array, queue, structure, enumeration, string... Including practical exercises)
- Tuowei information uses the cloud native landing practice of rainbow
- Kotlin combines flatmap for filtering and zip merge operators
- 解读创客思维与数学课程的实际运用
- opencv学习笔记四——膨胀/腐蚀/开运算/闭运算
- Splunk query CSV lookup table data dynamic query
- Open3D ISS关键点
- Battery and motor technology have received great attention, but electric control technology is rarely mentioned?
猜你喜欢
Make LIVELINK's initial pose consistent with that of the mobile capture actor
饥荒云服管理脚本
Fluentd is easy to use. Combined with the rainbow plug-in market, log collection is faster
[IELTS speaking] Anna's oral learning records part2
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
eBPF Cilium实战(2) - 底层网络可观测性
JS copy picture to clipboard read clipboard
【雅思口语】安娜口语学习记录 Part2
The field value in Splunk subquery fuzzy matching CSV is*
Coquette data completes the cloud native transformation through rainbow to realize offline continuous delivery to customers
随机推荐
数据中台落地实施之法
Deit learning notes
Standard function let and generic extension function in kotlin
Open3D ISS关键点
Kotlin combines flatmap for filtering and zip merge operators
Practice of combining rook CEPH and rainbow, a cloud native storage solution
Learn how to compile basic components of rainbow from the source code
Detailed explanation of apply, also, let, run functions and principle analysis of internal source code in kotlin
Rainbow version 5.6 was released, adding a variety of installation methods and optimizing the topology operation experience
解读创客思维与数学课程的实际运用
Interface as a parameter (interface callback)
探索STEAM艺术设计中的创造力
漏洞复现-Fastjson 反序列化
The largest 3 same digits in the string of leetcode simple question
Four items that should be included in the management system of integral mall
Several ways of lambda used in functions in kotlin (higher-order functions)
buureservewp(2)
XCiT学习笔记
Rainbow 5.7.1 supports docking with multiple public clouds and clusters for abnormal alarms
Leetcode medium question my schedule I