Skip to content

Filter Kubernetes resources by matching their names

License

Notifications You must be signed in to change notification settings

guessi/kubectl-grep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubectl Grep

GitHub Actions GoDoc Go Report Card GitHub release GitHub go.mod Go version

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

  • An existing Kubernetes cluster.
  • Have kubectl installed.
  • Have krew installed.

🚀 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?

What kind of resource(s) kubectl-grep support?

👷 Install

Recommended way

kubectl krew install grep && 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

⚖️ License

Apache-2.0