Kubectl Grep
![GitHub go.mod Go version](https://img.shields.io/github/go-mod/go-version/guessi/kubectl-grep)
Filter Kubernetes resources by matching their names
Requirements
- Kubernetes 1.24.0+
- Kubectl 1.24.0+
- Krew 0.4.3+
Compatibility
please refer to Kubernetes version policy and CHANGELOG for supported version matrix.
Example: kubectl-grep
build with Kubernetes-1.24.x should be compatable with Kubernetes cluster version 1.24, 1.25, 1.26.
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 is quite annoying.
Before change, we usually filter pods by the following commands,
$ kubectl get pods -n star-lab | grep "flash"
With this plugin installed, you can filter pod with kubectl grep
easily
$ kubectl grep pods -n star-lab flash
Installation
Installation via krew
$ kubectl krew version # make sure you are running 0.4.3+
$ kubectl krew install grep
$ kubectl krew update
$ kubectl krew upgrade grep
Manual Installation
$ curl -fsSL -O https://github.com/guessi/kubectl-grep/releases/latest/download/kubectl-grep-$(uname -s)-$(uname -m).tar.gz
$ tar zxvf kubectl-grep-$(uname -s)-$(uname -m).tar.gz
$ mv kubectl-grep /usr/local/bin
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?
Can I use version X kubectl
with version Y kubectl-grep
?
What kind of resource(s) kubectl-grep
support?
Reference
License
Apache-2.0