Shell

2021-09-23

命令

1
2
log [pod] [label]
log 服务名 虚拟标签

源码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
alias log='bash /Users/sunkz/Code/bash/log.bash'

#!/bin/bash

case $1 in
"exchange")
pod="sdb-supplier-exchange"
;;
"order")
pod="sdb-broker-order"
;;
"admin")
pod="sdb-broker-admin"
;;
"api")
pod="sdb-broker-api"
;;
"product")
pod="sdb-broker-product"
;;
*)
pod=""
;;
esac

kubectl get pods -n sdb | grep $pod | grep $2 | head -n 1 | awk '{print $1}' | xargs kubectl logs -n sdb -c $pod --since=1s -f