How to filter the running nodes

送分小仙女□ 提交于 2021-02-17 07:07:47

问题


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 hereconditions[]}{@.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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!