how to tell which pods are in a specific priority class?

3.6k Views Asked by At

Very basic question here: once I have created a priority-class, how do I query which pods are associated with / are in that priority class?

kubectl describe priorityclass <name>

gives details about the priority class itself

And I can get the details of the individual pod via:

kubectl get pod <name> -o yaml

But how do I query all pods that are in a particular priority class?

2

There are 2 best solutions below

1
On BEST ANSWER

This will do it:

kubectl get pods -o=jsonpath='{.items[?(@.spec.priorityClassName=="highpriority")].metadata.name}{"\n"}'

Change highpriority with whatever label you are using for your priority.

Hope it helps.

0
On

This will do it:

kubectl get pods --all-namespaces -o custom-columns=NAME:.metadata.name,PRIORITY:.spec.priorityClassName,VALUE:.spec.priority

You can change the namespace for specific one by replacing --all-namespaces with --namespace=<your_namespace>.

TIP: You can see what columns are available with -o yaml, for example:

kubectl get pods --all-namespaces -o yaml | grep -i priority