Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide Completed and other finished pods by default

In my professional environment it is common for "completed" pods to outnumber active ones and they often clutter the output of kubectl get pods like so:

$ kubectl get pods
finished-pod-38163    0/1 Completed    2m
errored-pod-83023     0/1 Error        2m
running-pod-20899     1/1 Running      2m

I can filter them out using --show-all=false:

$ kubectl get pods --show-all=false
running-pod-20899     1/1 Running      2m

However I would prefer not to have to type out --show-all=false every time I want to see my running pods. Is it possible to configure kubectl to disable --show-all by default rather than having it enabled by default?

From kubectl get pods --help:

-a, --show-all=true: When printing, show all resources (default show all pods
                     including terminated one.)

I know I could create some shell alias kgetpo, but this would remove support for tab-completion so I'd prefer native solutions if they exist.

like image 209
Cory Klein Avatar asked Sep 18 '25 14:09

Cory Klein


1 Answers

You can try something like this:

kubectl get pods --field-selector=status.phase==Running
like image 72
New User 77 Avatar answered Sep 21 '25 01:09

New User 77