kubectl-find

module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2025 License: Apache-2.0

README

kubectl-find

Ask DeepWiki Go Report Card GitHub License

It's a plugin for kubectl that gives you a UNIX find-like experience.

Find resource based on

  • name regex
  • age
  • labels
  • status
  • node name (for pods only)
  • restarts (for pods only)
  • image name (for pods only)

and then print, patch or delete any.

Usage

kubectl find [resource type | pods] [flags]

Flags:
  -r, --name string                    Regular expression to match resource names against; if not specified, all resources of the specified type will be returned.
  -n, --namespace string               If present, the namespace scope for this CLI request
  -A, --all-namespaces                 Search in all namespaces; if not specified, only the current namespace will be searched.
      --status string                  Filter pods by their status (phase); e.g. 'Running', 'Pending', 'Succeeded', 'Failed', 'Unknown'.
      --image string                   Regular expression to match container images against.
      --restarted                      Find pods that have been restarted at least once.
  -l, --selector string                Label selector to filter resources by labels.
      --max-age string                 Filter resources by maximum age; e.g. '2d' for 2 days, '3h' for 3 hours, etc.
      --min-age string                 Filter resources by minimum age; e.g. '2d' for 2 days, '3h' for 3 hours, etc.
      --node string                    Filter pods by node name regex; Uses pod.Spec.NodeName or pod.Status.NominatedNodeName if the former is empty.
  -h, --help                           help for kubectl find
  -p, --patch string                   Patch all found resources with the specified JSON patch.
  -e, --exec string                    Execute a command on all found pods.
      --delete                         Delete all matched resources.
  -f, --force                          Skip confirmation prompt before performing actions on resources.

Install

Using krew
krew install --manifest-url https://raw.githubusercontent.com/alikhil/kubectl-find/refs/heads/main/krew.yaml
Download binary

Download latest release for your platform/os and save it under $PATH as kubectl-find

Examples

Filter using regex

Instead of

kubectl get pods -o name | grep test

Run

kubectl find -r test
Filter by resource age
kubectl find cm --min-age 1d -A --name spark
Execute command on several pods
kubectl find pods -l app=nginx --exec 'nginx -s reload'
Find all failed pods and delete them
kubectl find pods --status failed -A --delete
Find restarted pods
kubectl find --restarted

Completion

Copy kubectl_complete-find script somewhere under PATH.

Directories

Path Synopsis
pkg
cmd
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL