【CKA模拟题】查找集群中使用内存最高的node节点

题干

For this question, please set this context (In exam, diff cluster name)

shell 复制代码
kubectl config use-context kubernetes-admin@kubernetes

Find the Node that consumes the most MEMORY in all cluster(currently we have single cluster). Then, store the result in the file high_memory_node.txt with the following format: cluster_name,node_name .

找出所有集群中消耗内存最多的节点(目前我们只有一个集群)。然后,将结果以以下格式存储在high_memory_node.txt文件中:cluster_name,node_name

解题思路

  1. 切换K8S集群环境
shell 复制代码
kubectl config use-context kubernetes-admin@kubernetes
  1. 查找集群中节点内存使用最多的节点,并把结果存在变量node中
shell 复制代码
node=$(kubectl top nodes --sort-by=memory --no-headers | head -n 1 | awk '{print $1}')
  1. 查找集群名称
shell 复制代码
cluster_name=$(kubectl config view --minify -o=jsonpath='{.clusters[0].name}')
  1. 并按照题目的要求把结果输出到指定文件中
shell 复制代码
echo "$cluster_name,$node" > high_memory_node.txt
相关推荐
Sirens.3 小时前
twikoo:从MongoDB Atlas到本地部署
运维·服务器
Meya11273 小时前
别再人工硬扛机房管理!智能 U 位系统,让机房管理一键数字化
大数据·运维
DFT计算杂谈4 小时前
自动化脚本一键绘制三元化合物相图
java·运维·服务器·开发语言·前端·python·自动化
Yupureki4 小时前
《Linux网络编程》6.UDP原理
linux·运维·服务器·网络·udp
楼田莉子4 小时前
Linux网络:NAT_代理
linux·运维·服务器·开发语言·c++·后端
阿里云云原生4 小时前
HiClaw 上线 Worker 模板市场,提供稳定可共享的 Agent 生产力
云原生
Harvy_没救了5 小时前
【网络运维】 WordPress 部署复盘
运维·网络
weixin_402278456 小时前
VS code 本地推送github添加SSH设置
运维·git·ssh
fish_xk6 小时前
Linux的权限
linux·运维·服务器
嵌入式×边缘AI:打怪升级日志7 小时前
Linux 驱动与应用开发核心自测题库(面试官问答完整版)
linux·运维·php