How to filter pod which are in running & completed status using field selector

Viewed 544

I am applying below command to get the pods which are in running state:

oc get pods --field-selector=status.phase=Running 

I can get pods which are in running state. But I want to pods which are in Running and Completed state

How can we apply OR logic on status of the POD?

1 Answers

--field-selector does not allow OR logic.

Try this using grep kubectl get pod | grep "Running\|Completed"

Or with awk kubectl get po | awk '{ if ($3 == "Running" || $3 == "Completed") { print } }'

Related