【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
相关推荐
小晶晶京京42 分钟前
day34-LNMP详解
linux·运维·服务器
fengyehongWorld1 小时前
Linux crontab定时任务
linux·运维
碎像2 小时前
Linux上配置环境变量
linux·运维·服务器
40kuai2 小时前
kubernetes中数据存储etcd
容器·kubernetes·etcd
sunflower_w4 小时前
linux I2C核心、总线与设备驱动
linux·运维·服务器
myzzb4 小时前
基于uiautomation的自动化流程RPA开源开发演示
运维·python·学习·算法·自动化·rpa
Harvey_D4 小时前
【部署K8S集群】 1、安装前环境准备配置
云原生·容器·kubernetes
网硕互联的小客服5 小时前
Apache 如何支持SHTML(SSI)的配置方法
运维·服务器·网络·windows·php
落日漫游6 小时前
K8s核心组件全解析
运维·docker·运维开发
Demisse8 小时前
[Linux] Linux文件系统基本管理
linux·运维·服务器