kalitsov
kalitsov

Reputation: 1639

How to filter pods based on status in k9s

Often there is more than one search result returned from / filter command which is confirm by pressing Enter. Then I can navigate the results, but have no way to filter based on data displayed e.g. Status or CPU.

QUESTION: Is this possible? If so, what I need to do to achieve it?

enter image description here

Upvotes: 20

Views: 13302

Answers (3)

krzystooof
krzystooof

Reputation: 63

You can filter results using / just like with :

As @dgebert said for sorting use SHIFT + first letter of keyword to sort by

Upvotes: 6

dgebert
dgebert

Reputation: 1484

I don't think it's possible to filter search result, but you can sort them, which can be helpful in most cases. For example:

  • SHIFT+C sorts by CPU
  • SHIFT+M sorts by MEMORY
  • SHIFT+S sorts by STATUS
  • ...

Upvotes: 33

Hiren Namera
Hiren Namera

Reputation: 424

you can try something like this where replace ImagePullBackOff with filter of your need

kubectl get pod -o=json | jq '.items[]|select(any( .status.containerStatuses[]; .state.waiting.reason=="ImagePullBackOff"))|.metadata.name'

Upvotes: 1

Related Questions