【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
相关推荐
j_xxx404_6 小时前
Linux:进程程序替换
linux·运维·服务器
RisunJan6 小时前
Linux命令-lnstat(快速查找文件和目录)
linux·运维·服务器
lihui_cbdd7 小时前
Slurm 集群内存管理与限制配置
运维·服务器
历程里程碑7 小时前
Linux 17 程序地址空间
linux·运维·服务器·开发语言·数据结构·笔记·排序算法
Wpa.wk7 小时前
容器编排 - K8s - 配置文件参数说明和基础命令
经验分享·测试工具·docker·云原生·容器·kubernetes
H Journey7 小时前
Linux 下添加用户相关
linux·运维·服务器·添加用户
零基础的修炼8 小时前
Linux网络---网络层
运维·服务器·网络
Trouvaille ~8 小时前
【Linux】线程同步与互斥(三):生产者消费者模型实战
linux·运维·c++·信号量·阻塞队列·生产者消费者模型·环形队列
遇见火星8 小时前
Linux Screen 命令入门指南
linux·运维·服务器
Doro再努力8 小时前
【Linux操作系统06】深入理解权限掩码与粘滞位
linux·运维·服务器