【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
相关推荐
Narutolxy18 分钟前
Ubuntu 下 Docker 企业级运维指南:核心命令与最佳实践深度解析20250309
运维·ubuntu·docker
明明跟你说过41 分钟前
在【k8s】中部署Jenkins的实践指南
运维·ci/cd·云原生·容器·kubernetes·jenkins
酥暮沐44 分钟前
K8S 集群搭建——cri-dockerd版
linux·容器·kubernetes
a_j581 小时前
k8s面试题总结(十)
云原生·容器·kubernetes
沉默的八哥1 小时前
RBAC的工作原理,以及如何限制特定用户访问
运维·kubernetes
一条闲鱼_mytube1 小时前
[Kubernetes] 7控制平面组件
java·平面·kubernetes
琪琪花2 小时前
sshfs 将远程服务器上的文件系统挂载到本地目录
linux·运维·服务器
wayuncn2 小时前
哈尔滨服务器租用的流程
运维·服务器
对许3 小时前
FusionInsight MRS云原生数据湖
云原生·fusioninsight·mrs
blasit4 小时前
keil 5 MDK 安装失败提示Cannot create destination file."文件名、目录名或卷标语法不正确"
运维·程序员·如何当个好爸爸