Hello all, I tried to check the nodes which is Ready status, and did it followin . . .

양상헌:
Hello all,
I tried to check the nodes which is Ready status, and did it following the K8S cheetsheet ;

root@master:/# k get nodes
NAME STATUS ROLES AGE VERSION
master Ready master 9d v1.19.5
node1 Ready <none> 9d v1.19.5
node2 Ready <none> 9d v1.19.5
node3 NotReady <none> 9d v1.19.5
root@master:/# JSONPATH=’{range .items[]}{@.metadata.name}:{range @.status.conditions[]}{@.type}={@.status};{end}{end}’
> && kubectl get nodes -o jsonpath="$JSONPATH" | grep “Ready=True”
master:NetworkUnavailable=False;MemoryPressure=False;DiskPressure=False;PIDPressure=False;Ready=True;node1:NetworkUnavailable=False;MemoryPressure=False;DiskPressure=False;PIDPressure=False;Ready=True;node2:NetworkUnavailable=False;MemoryPressure=False;DiskPressure=False;PIDPressure=False;Ready=True;node3:NetworkUnavailable=False;MemoryPressure=Unknown;DiskPressure=Unknown;PIDPressure=Unknown;Ready=Unknown;
root@master:/#

Is this correct output or jsonpath is wrong ?
(I expected just the node name which is Ready)

Tej_Singh_Rana:
Hello, @양상헌
Before grapping specific word. Did you try to run only query?
e.g.
JSONPATH=’{range .items[]}{@.metadata.name}:{range @.status.conditions[]}{@.type}={@.status};{end}{end}’
> && kubectl get nodes -o jsonpath="$JSONPATH"

Tej_Singh_Rana:

JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{"\n"}{end}'

kubectl get nodes -o jsonpath="$JSONPATH" | grep -w "Ready=True" |cut -d':' -f 1

양상헌:
it works~, adding {"\n"} is important factor to be used with grep…k8s cheetsheet should be modified like you did…,thanks Tej ~ !!