Home > Blockchain >  How to filter pods based on status in k9s
How to filter pods based on status in k9s

Time:06-10

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

CodePudding user response:

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
  • ...

CodePudding user response:

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'
  • Related