https://github.com/FingerLiu/kubectl-smart
![demo]( https://github.com/FingerLiu/kubectl-smart/raw/main/imgs/kubectl-smart.gif
给 kubectl 支持了正则匹配功能,不管是 namespace 还是资源名,都可以模糊查找。 主要解决了以下两个痛点:
kubectl s g deploy my
即可kubectl s l deploy-name
即可Type less, Live more! 俩字,好使。
curl -LO https://github.com/FingerLiu/kubectl-smart/raw/master/kubectl-smart
chmod +x ./kubectl-smart
sudo mv ./kubectl-smart /usr/local/bin/kubectl-s
kubectl s -h
Examples:
# if you installed through krew, you should **kubectl smart** to replace **kubectl s**
# get pod with name contains my in namespace her-namespace
# (kubectl get pod -n her-namespace-a |grep my)
kubectl s gp -n her.*a my
# get log for pod with name my
# (kubectl logs --tail 100 -f $(kubectl get pods | awk '/my/ {print $1;exit}'))
kubectl s l my
# exec into pod
# kubectl exec -ti my-pod-i3jx bash
kubectl s e my bash
# get deploy with name contains my
# (kubectl get deploy | grep my)
kubectl s g deploy my
1
AnyISalIn 2021-03-16 21:07:56 +08:00
🐮 楼主说的日志场景 stern 可以搞定
|
2
mritd 2021-03-17 08:27:11 +08:00 via iPhone
我都是 ohmyzh tab 一手
|
3
hwdef 2021-04-14 16:00:26 +08:00
🤪相比之下,正则更难
|
5
xabcstack 2021-09-28 16:50:37 +08:00
可以看看 Kubectl Pro https://github.com/ywgx/ki 风味更佳
|