kubernetes - 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 ?
解决方案
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
推荐阅读
- liquid - Jekyll 站点中的 Liquid 在一页上构建时抛出错误 - 如果代码在包含中则有效
- flutter - Flutter/Dart Non-Nullable - 直接使用快照数据
- python - 使用 dask 的并行化很差
- javascript - JSX.Element 作为接口 TS 中的道具
- python - 如何一次将文件推送到多个 Raspberry Pi Pico?
- kubernetes - 如何在 GKE 和 Kong Ingress 上设置每秒请求数限制?
- css - CSS 缓出闪烁
- java - Java:如何更新现有的 csv 文件而不创建新文件?
- wordpress - 是否可以在更新到数据库之前和之后记录 wordpress / woocommerce 帖子元值?
- firebase - Firebase 仅托管以前版本的 Flutter Web 应用