# Kubectl Grep
[](https://circleci.com/gh/guessi/kubectl-grep)
[](https://godoc.org/github.com/guessi/kubectl-grep)
[](https://goreportcard.com/report/github.com/guessi/kubectl-grep)
[](https://github.com/guessi/kubectl-grep/releases/latest)
[](https://github.com/guessi/kubectl-grep/blob/master/go.mod)
Filter Kubernetes resources by matching their names
# Requirements
- Kubernetes 1.17.0+
- Kubectl 1.17.0+
- Krew 0.4.0+
# Compatibility
please refer to [Kubernetes version policy](https://kubernetes.io/docs/setup/release/version-skew-policy/#kubectl) and [CHANGELOG](CHANGELOG.md) for supported version matrix.
Example: `kubectl-grep` build with Kubernetes-1.19.x should be compatable with Kubernetes cluster version 1.18, 1.19, 1.20.
# Why we need it?
playing with Kubernetes is my daily job, and I normally search pods by `pipe`,
`grep`, `--label`, `--field-selector`, etc. while hunting abnormal pods, but
typing such long commands are quite annoyed.
Before change, we usually filter pods by the following commands,
$ kubectl get pods | grep "keyword"
$ kubectl get pods -o wide | grep "keyword"
$ kubectl get pods -n "my-ns" | grep "keyword"
$ kubectl get pods -A | grep "keyword"
$ kubectl get pods -l "key=value" | grep "keyword"
$ kubectl get pods -l "key=value" -n "my-ns" | grep "keyword"
$ kubectl get pods -l "key=value" -A | grep "keyword"
With this plugin installed, you can filter pod with `kubectl grep` easily
$ kubectl grep pods "keyword"
$ kubectl grep pods "keyword" -o wide
$ kubectl grep pods "keyword" -n "my-ns"
$ kubectl grep pods "keyword" -A
$ kubectl grep pods "keyword" -l "key=value"
$ kubectl grep pods "keyword" -l "key=value" -n "my-ns"
$ kubectl grep pods "keyword" -l "key=value" -A
# Supported Resources
- [X] ConfigMaps
- [X] DaemonSets
- [X] Deployments
- [X] HPAs
- [X] Ingresses
- [X] Jobs
- [X] Nodes
- [X] Pods
- [X] Secrets
- [X] StatefulSets
# Installation
Installation via [krew](https://krew.sigs.k8s.io/docs/user-guide/setup/install/)
$ kubectl krew version # make sure you are running 0.4.0+
$ kubectl krew install grep
$ kubectl krew upgrade
Manual Installation
$ export KUBECTL_GREP_VERSION=$(curl -s https://api.github.com/repos/guessi/kubectl-grep/releases/latest | jq -r .tag_name)
$ curl -L -O https://github.com/guessi/kubectl-grep/releases/download/${KUBECTL_GREP_VERSION}/kubectl-grep-$(uname -s)-$(uname -m).tar.gz
$ tar zxvf kubectl-grep-$(uname -s)-$(uname -m).tar.gz
$ mv kubectl-grep /usr/local/bin
$ chmod +x /usr/local/bin/kubectl-grep
# Examples
List all pods in default namespace,
$ kubectl grep pods
List all pods in all namespaces,
$ kubectl grep pods -A
List all pods with specific keyword, under specific namespace,
$ kubectl grep pods -n star-lab flash
# How to get developer build?
$ go get -u github.com/guessi/kubectl-grep
$ cd ${GOPATH}/src/github.com/guessi/kubectl-grep
$ make all
# FAQ
How do I check the tool's version?
$ kubectl grep version
Any plan to support Kubernetes version before 1.10.0?
sorry, it only support Kubernetes 1.10.0+
I'm now running Kubernetes 1.10.0, do I need to upgrade my cluster?
nope, the only requirement is to upgrade your `kubectl` to 1.13.0+
Can I run Kubernetes 1.12.0 with kubectl 1.13.0?
sure, no problem
# Reference
- [Kubectl Plugins](https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/)
# License
[Apache-2.0](LICENSE)

LunaKnight
- 粉丝: 47
最新资源
- 本库是个基于python的工具集,用于记录数据到文件。 使用方便,代码简洁, 是一个可靠、省心且实用的工具。 支持多线程同时写入。.zip
- 本科毕业设计,基于python的图像复制粘贴篡改识别软件。.zip
- 本项目是基于计算机视觉的端到端交通路口智能监控系统.采用的设计架构由SRS
- 碧蓝航线ios平台自动脚本,基于python+opencv+facebook_wda实现.zip
- 毕业设计中基于给定微博数据的反作弊识别,用python开发。.zip
- 毕业设计项目,基于深度学习的实时语义分割算法研究,python实现。.zip
- 对基于python的微博爬虫进行重写,重写语言:java.zip
- 此框架是基于Python+Pytest+Requests+Allure+Yaml+Json实现全链路接口自动化测试
- 程序语言课程作业在线评测平台(实现Java、C、Python的选择、填空、代码题在线评测),基于SpringBoot+Layui+MySQL实现.zip
- 非官方的科大讯飞语音合成(用于朗读,配音场景)python API (基于官方demo增加了:超过2000字上限自动分割再合并音频的功能).zip
- 非官方的简易中国铁路列车运行图系统,基于Python + PyQt5
- 超市POS销售与后台管理系统_商品录入收银业务会员管理进货销售库存人员权限断网收银断电保护_实现超市前台POS销售商品扫描条形码输入收银计算找零打印清单会员折扣累计消费以及后台管理.zip
- 俄罗斯方块闯关版,基于Python实现.zip
- 该项目是基于Python和数据库实现的学生信息管理系统.zip
- 该仓库为agv系统调度软件的前后端实现。项目基于fastapi(python后端框架)和vue2实现了RESTful风格的前后端分离.zip
- 该项目是基于Scrapy框架的Python新闻爬虫,能够爬取网易,搜狐,凤凰和澎湃网站上的新闻,将标题,内容,评论,时间等内容整理并保存到本地.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈


