【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
相关推荐
撸码到无法自拔29 分钟前
云计算-私有云-私有云服务运维
运维·云计算
极小狐2 小时前
如何使用极狐GitLab 软件包仓库功能托管 maven?
java·运维·数据库·安全·c#·gitlab·maven
小马爱打代码3 小时前
K8S - 蓝绿发布实战 - Argo Rollouts 零停机方案解析
云原生·容器·kubernetes
檀越剑指大厂5 小时前
【Docker系列】docker inspect查看容器部署位置
运维·docker·容器
江湖人称-杰5 小时前
CentOS配置了镜像源之后依旧下载元数据失败
linux·运维·centos
A尘埃6 小时前
K8S有状态服务部署(MySQL、Redis、ES、RabbitMQ、Nacos、ZipKin、Sentinel)
redis·mysql·kubernetes
BXCQ_xuan7 小时前
DNS负载均衡和CDN的区别
运维·负载均衡
purrrew8 小时前
【Java ee初阶】网络原理
java·运维·服务器·网络·网络协议·udp·java-ee
滴水之功8 小时前
Ubuntu22.04怎么退出Emergency Mode(紧急模式)
linux·运维·服务器
明仔丶9 小时前
开启docker中mysql的binlog日志
运维·docker·容器·binlog