kubectl-find is a kubectl plugin inspired by UNIX find. It searches Kubernetes resources by name, status, age, image, node, and custom conditions, then can act on the matches.

Install

krew install fd

Common searches

Find pods by name:

kubectl fd pods -r dev

Find pods with restarted containers:

kubectl fd pods --restarted

Find pods with images matching a pattern:

kubectl fd pods --image bitnami

Find any resource with a custom jq condition:

kubectl fd svc -j '.spec.trafficDistribution == "PreferClose"'

Actions

By default, kubectl fd prints matching resources. It can also act on matches:

  • --delete - delete matching resources
  • --patch - patch matching resources with JSON
  • --exec - run a command in matching pods