Kubectl Grep
June 1, 2025 ยท View on GitHub
Filter Kubernetes resources by matching their names
๐ค Why we need this? what it is trying to resolve?
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.
๐ข Prerequisites
๐ Quick start
# 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
:accessibility: FAQ
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
๐ท Install
Recommended way
Brand new install
kubectl krew update && kubectl krew install grep
To upgrade version
kubectl krew update && kubectl krew upgrade grep
Manual Installation
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
Developer build
Click to expand!
go get -u github.com/guessi/kubectl-grep
cd ${GOPATH}/src/github.com/guessi/kubectl-grep
make all