【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
相关推荐
妄想出头的工业炼药师9 分钟前
cuda如何安装卸载
linux·运维·服务器
泡沫·10 分钟前
3.sed 使用手册
运维
阿里云云原生12 分钟前
云监控 UModel Explorer:用“图形化”重新定义可观测数据建模
云原生
WangLanguager20 分钟前
SVD介绍和代码示例
运维
柳鲲鹏21 分钟前
LINUX下载编译libcamera
linux·运维·服务器
泡沫·23 分钟前
2.grep使用手册
运维
天命码喽c24 分钟前
Docker-compose部署GraphRAG-2.7.0
运维·docker·容器
init_236144 分钟前
【BGP入门专题-5】bgp路由反射器RR
运维·网络
遇见火星1 小时前
Linux下挂载磁盘相关命令
linux·运维·服务器·磁盘·lsblk·fdisk