【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
相关推荐
CodexDave19 分钟前
数据库连接池耗尽:排查顺序与三层兜底
服务器·前端·数据库·git·云原生·容器·kubernetes
weixin_3077791320 分钟前
Linux下Jenkins数据故障的系统化排查Shell脚本
linux·运维·服务器·jenkins
荒--28 分钟前
Burp Suite(二)
linux·运维·服务器
YangYang9YangYan42 分钟前
2026自动化背景无项目经验转数据分析的可行性分析
运维·数据分析·自动化
internet Boy1 小时前
服务器机房硬件入门教程
运维·服务器
小白还菜1 小时前
linux(Debian)使用mdadm组磁盘RAID1阵列
linux·运维
三8442 小时前
BGP/BGP路由反射器/联邦/BGP属性/BGP选路
运维·服务器·网络
Lumistory2 小时前
超高层地标泛光照明落地:从方案到运维的避坑思路
运维·光照贴图
Urbano3 小时前
工装夹克、职业单西口袋工艺自动化改造深度解析
运维·自动化
草莓熊Lotso3 小时前
【Linux网络】深入理解Linux IO多路复用:从本质到select服务器实战
linux·运维·服务器·c语言·网络·数据库·c++