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)
- direct controller (for pods only)
- jq filter - custom condition
Use --not before a filter to exclude its matches. It remains active for later
filters, so place inclusive filters before it:
kubectl fd pods -r "prod" --not -r "beta"
kubectl fd pods -l app=nginx --not -l version=1.20
kubectl fd pods --host host-1 --not --restarted
kubectl fd pods --not -n kube-system
kubectl fd pods --not --controller apps/daemonsets--not -n <namespace> searches all namespaces and excludes that namespace.
and then print, patch, annotate, delete, restart workloads, or manage matching nodes.
kubectl fd [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.
--controller string Filter pods by their direct controller; format: API-GROUP/RESOURCE (e.g. apps/daemonsets).
-j, --jq string jq expression to filter resources; Uses gojq library for evaluation.
--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.
-L, --labels strings Comma-separated list of labels to show.
-T, --annotations strings Comma-separated list of annotations to show.
-N, --node-labels strings Comma-separated list of node labels to show.
--natural-sort Sort resource names in natural order.
-o, --output string Output format: json, yaml, kyaml, name, go-template=EXPR (or gotemplate=EXPR), or jsonpath=EXPR.
-h, --help help for kubectl fd
-p, --patch string Patch all found resources with the specified JSON patch.
-e, --exec string Execute a command on all found pods.
--annotate string Annotate all found resources; format: k=v[,k2=v2] to add/overwrite or k- to remove annotations.
--delete Delete all matched resources.
--evict Evict all matched pods, respecting PodDisruptionBudgets.
--cordon Cordon all matched nodes.
--uncordon Uncordon all matched nodes.
--drain Cordon and drain all matched nodes.
--restart Restart all matched deployments, daemonsets, or statefulsets.
-y, --skip-confirm Skip confirmation prompt before performing actions on resources.
--force If true, immediately remove resources from API and bypass graceful deletion. Can only be used with --delete flag.Using krew
krew install fdDownload latest release for your platform/os and save it under $PATH as kubectl-fd
Without -o, kubectl fd prints its table output. Use -o for machine-readable
or targeted output:
kubectl fd pods -o json
kubectl fd nodes -o yaml
kubectl fd nodes -o kyaml
kubectl fd pods -o name
kubectl fd pods -o 'go-template={{range .items}}{{.metadata.name}}{{"\\n"}}{{end}}'
kubectl fd pods -o 'jsonpath={.items[*].metadata.name}'Based on gojq implementation of jq.
Check resource structure on kubespec.dev.
kubectl fd pods -j '.spec.nodeSelector == null' -Akubectl fd pods -j 'any( .spec.containers[]; .resources == {} )' -AInstead of
kubectl get pods -o name | grep testRun
kubectl fd -r testkubectl fd cm --min-age 1d -A --name sparkkubectl fd pods -l app=nginx --exec 'nginx -s reload'kubectl fd pods --status failed -A --deleteEviction respects PodDisruptionBudgets, unlike deleting a pod directly.
kubectl fd pods -l app=api --evictkubectl fd nodes --name 'worker-.*' --cordon
kubectl fd nodes --not --name 'control-plane.*' --drain --drain-ignore-daemonsets --drain-delete-emptydir-data --force
kubectl fd nodes --name 'worker-.*' --uncordon--drain supports --force, --drain-ignore-daemonsets,
--drain-delete-emptydir-data, --drain-grace-period, --drain-timeout,
--drain-pod-selector, --drain-disable-eviction,
--drain-skip-wait-for-delete-timeout, and --drain-chunk-size.
--restart performs the same rollout restart as kubectl rollout restart for
deployments, daemonsets, and statefulsets.
kubectl fd deployments -l app=api --restartkubectl fd pods -r nginx --annotate 'team=backend,env=production'kubectl fd pods --status Running --annotate 'deprecated-'kubectl fd pods -l app=nginx --annotate 'owner=team-a,old-owner-'kubectl fd --restarted--controller matches a pod's direct controller owner. For example, a
Deployment pod is directly controlled by a ReplicaSet, not the Deployment.
# Include only DaemonSet-managed pods
kubectl fd pods --controller apps/daemonsets
# Exclude DaemonSet-managed pods
kubectl fd pods --not --controller apps/daemonsetsk fd -L app.kubernetes.io/component
NAME READY STATUS RESTARTS AGE COMPONENT
admin-backend-server-6fb6bbb8f6-2xntp 1/1 Running 0 7h4m deployments-server
admin-frontend-nginx-b8c88b7b4-pxx2x 1/1 Running 0 3h7m deployments-nginx
top-react-ok-app-develop-nginx-586c65496f-h4b9p 1/1 Running 0 11h deployments-nginx
top-react-ok-app-stage-nginx-8595cbfb6c-qzt2z 1/1 Running 0 11h deployments-nginx
nginx 1/1 Running 0 18d <none>
redis-redis-ha-server-0 1/1 Running 0 11h <none>
super-admin-server-65d57f8787-5c9sd 1/1 Running 0 11h deployments-server
ok-web-app-nginx-5c78887cbf-2n8fw 1/1 Running 0 11h deployments-nginxk fd -N topology.kubernetes.io/zone
NAME READY STATUS RESTARTS AGE NODE ZONE
admin-backend-server-6fb6bbb8f6-2xntp 1/1 Running 0 7h5m nodeee-short-2 eu-central1-b
admin-frontend-nginx-b8c88b7b4-pxx2x 1/1 Running 0 3h8m nodeee-short-2 eu-central1-b
top-react-ok-app-develop-nginx-586c65496f-h4b9p 1/1 Running 0 11h nodeee-short-2 eu-central1-b
top-react-ok-app-stage-nginx-8595cbfb6c-qzt2z 1/1 Running 0 11h nodeee-short-2 eu-central1-b
nginx 1/1 Running 0 18d nodeee-long-3 eu-central1-b
redis-redis-ha-server-0 1/1 Running 0 11h nodeee-short-2 eu-central1-b
super-admin-server-65d57f8787-5c9sd 1/1 Running 0 11h nodeee-short-2 eu-central1-b
ok-web-app-nginx-5c78887cbf-2n8fw 1/1 Running 0 11h nodeee-short-2 eu-central1-b
zipkin-ok-shop-zipkin-5d94fcdc67-r8pcx 1/1 Running 0 10d nodeee-long-1 eu-central1-bk fd -T example.com/owner
NAME READY STATUS RESTARTS AGE OWNER
admin-backend-server-6fb6bbb8f6-2xntp 1/1 Running 0 7h4m team-a
admin-frontend-nginx-b8c88b7b4-pxx2x 1/1 Running 0 3h7m team-b
top-react-ok-app-develop-nginx-586c65496f-h4b9p 1/1 Running 0 11h team-a
nginx 1/1 Running 0 18d <none>Normal sort
kubectl fd
NAME READY STATUS RESTARTS AGE
nginx-0 1/1 Running 0 5m14s
nginx-1 1/1 Running 0 5m12s
nginx-10 1/1 Running 0 4m53s
nginx-11 1/1 Running 0 4m50s
nginx-12 1/1 Running 0 4m48s
nginx-13 1/1 Running 0 4m46s
nginx-14 1/1 Running 0 4m44s
nginx-2 1/1 Running 0 5m10s
nginx-3 1/1 Running 0 5m7s
nginx-4 1/1 Running 0 5m5s
nginx-5 1/1 Running 0 5m3s
nginx-6 1/1 Running 0 5m1s
nginx-7 1/1 Running 0 4m59s
nginx-8 1/1 Running 0 4m57s
nginx-9 1/1 Running 0 4m55sNatural sort
kubectl fd --natural-sort
NAME READY STATUS RESTARTS AGE
nginx-0 1/1 Running 0 6m6s
nginx-1 1/1 Running 0 6m4s
nginx-2 1/1 Running 0 6m2s
nginx-3 1/1 Running 0 5m59s
nginx-4 1/1 Running 0 5m57s
nginx-5 1/1 Running 0 5m55s
nginx-6 1/1 Running 0 5m53s
nginx-7 1/1 Running 0 5m51s
nginx-8 1/1 Running 0 5m49s
nginx-9 1/1 Running 0 5m47s
nginx-10 1/1 Running 0 5m45s
nginx-11 1/1 Running 0 5m42s
nginx-12 1/1 Running 0 5m40s
nginx-13 1/1 Running 0 5m38s
nginx-14 1/1 Running 0 5m36sCopy kubectl_complete-fd script somewhere under PATH.