Filter Kubernetes resources by matching their names
Playing with Kubernetes in our daily job, we normally search pods by pipe
, grep
, --label
, --field-selector
, etc. while hunting abnormal pods, but typing such long commands is quite annoying. With plugin installed, it could be easily be done by kubectl grep
.
# Have krew plugin installed
kubectl krew install grep
# 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 easily
kubectl grep pods -n star-lab flash
How do I check the version installed?
kubectl grep version
How do I know the version installed is compatible with my cluster version?
- Ideally, it should be compatible with supported Kubernetes versions.
What kind of resource(s) kubectl-grep
support?
- Please refer to Resource Types
kubectl krew install grep && kubectl krew update && kubectl krew upgrade grep
Click to expand!
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
Click to expand!
go get -u github.com/guessi/kubectl-grep
cd ${GOPATH}/src/github.com/guessi/kubectl-grep
make all