首页 > 解决方案 > how to list the number of ready nodes in a cluster which don't have a taint

问题描述

Want to list the number of ready nodes without any taint. I get the list of nodes using below query:

kubectl get nodes -o json|jq -jr '{.items[]|select(.spec.taints|not)|select(.status.conditions[].type=="Ready" and .status.conditions[].status="True")|.metadata.name+"\n"}'

This gives me below output

node01
node01

How to I get number of nodes instead of actual node names from this query ?

标签: kubernetes

解决方案


Use this for number of nodes with "No taint":

kubectl get nodes -o json | jq '.items[] | select(.spec.taints|not) | .metadata.name' | wc -l

Get number of nodes with "Ready" status and "No taint":

kubectl get nodes -o json|jq -r '.items[]|select(.status.conditions[].type=="Ready")|select(.spec.taints|not).metadata.name' | wc -l

推荐阅读