美文网首页
备战CKA每日一题——第14天

备战CKA每日一题——第14天

作者: 小E的私房菜 | 来源:发表于2020-03-13 16:25 被阅读0次

第十四题:

题:统计node是ready状态,(不包含node的污点,没有调度的)


题目:check to see how many nodes are ready (not including nodes tained NoSchedule) and write the number to /opt/nodenum
解题思路:
  • 纯考kubectl指令,grep -w是精确匹配:

grep [options]:

主要参数:  grep --help可查看
    -c:只输出匹配行的计数。
    -i:不区分大小写。
    -h:查询多文件时不显示文件名。
    -l:查询多文件时只输出包含匹配字符的文件名。
    -n:显示匹配行及 行号。
    -s:不显示不存在或无匹配文本的错误信息。
    -v:显示不包含匹配文本的所有行。
    --color=auto :可以将找到的关键词部分加上颜色的显示。
解题步骤:
  1. 创建文件:/opt/nodenum
sudo touch /opt/nodenum

2.通过下面命令,统计Ready数量N:

kubectl get node | grep -w  Ready | wc -l

3.通过下面命令,统计NoSchedule和Taints数量M

 sudo kubectl describe nodes | grep Taints | grep -I NoSchedule | wc -l > /opt/nodenum

相关文章

网友评论

      本文标题:备战CKA每日一题——第14天

      本文链接:https://www.haomeiwen.com/subject/cejlshtx.html