Kubectl get only nodes with status ready

9/17/2020

I want to get the list of active nodes using kubectl. Is there a flag to do this. At the moment, I am just running

kubectl get node

-- Clement Okyere
kubernetes

1 Answer

9/17/2020

You can do this

kubectl get nodes | grep Ready

or you can do this

JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]} 
{@.type}={@.status};{end}{end}' \
&& kubectl get nodes -o jsonpath="$JSONPATH" | grep "Ready=True"
-- Dashrath Mundkar
Source: StackOverflow