问题
I want to filter the running nodes list . I tried below command but its only showing running status.I need to filter with it name..Any help ?
[root@techsl]# kubectl get nodes -o jsonpath='{range .items[]}{@.metadata.name}:{range @.status.enter code here
conditions[]}{@.type}={@.status};{end}{end}'| tr ';' "\n" | grep "Ready=True"
回答1:
Something like this is easier:
kubectl get nodes | grep -v NotReady | awk '{print $1}' | tail -n2
server1
server3
kubectl get nodes
NAME STATUS ROLES AGE VERSION
server1 Ready master 106d v1.14.9
server2 NotReady <none> 106d v1.14.9
server3 Ready <none> 106d v1.14.9
回答2:
kubectl get nodes -o jsonpath="{range .items[*]}{@.metadata.name}: {range @.status.conditions[4]}{@.type}; {end}{end}";
kubernetes-1-17-master: Ready; kubernetes-1-17-worker: Ready;
The way you do:
kubectl get nodes -o jsonpath="{range .items[*]}{@.metadata.name}:{range @.status.conditions[4]}{@.type}={@.status}; {end}{end}" | grep "Ready=True"
kubernetes-1-17-master:Ready=True; kubernetes-1-17-worker:Ready=True;
来源:https://stackoverflow.com/questions/60650401/how-to-filter-the-running-nodes