背景:kubectl top命令可以查看node或者pod的cpu和内存的使用情况,所以我们安装kubectl top命令,这里我使用helm 安装,具体步骤如下:

1、首先添加helm 仓库

helm repo add bitnami https://charts.bitnami.com/bitnami

2、在仓库里搜索chart名字

[root@master base]# helm search repo metrics-server

NAME CHART VERSION APP VERSION DESCRIPTION

bitnami/metrics-server 4.3.1 0.3.7 Metrics Server is a cluster-wide aggregator of ...

3、使用helm安装

[root@master base]# helm install metrics-server bitnami/metrics-server -n kube-system

4、安装完后会看到以下错误提示:

** Please be patient while the chart is being deployed **

The metric server has been deployed.

########################################################################################

### ERROR: The metrics.k8s.io/v1beta1 API service is not enabled in the cluster ###

########################################################################################

You have disabled the API service creation for this release. As the Kubernetes version in the cluster

does not have metrics.k8s.io/v1beta1, the metrics API will not work with this release unless:

Option A:

You complete your metrics-server release by running:

helm upgrade metrics-server bitnami/metrics-server \

--set apiService.create=true

解决方法:

按着他的提示开启apiService服务

[root@master ~]# helm upgrade metrics-server bitnami/metrics-server --set apiService.create=true -n kube-system

然后会得到以下返回值:

NAME: metrics-server

LAST DEPLOYED: Wed Sep 16 16:59:01 2020

NAMESPACE: kube-system

STATUS: deployed

REVISION: 1

TEST SUITE: None

NOTES:

** Please be patient while the chart is being deployed **

The metric server has been deployed.

In a few minutes you should be able to list metrics using the following

command:

kubectl get --raw "/apis/metrics.k8s.io/v1beta1/nodes"

按他提示的命令查询一下,以验证安装是否成功,如果安装成功会返回一堆值,如果安装不成功使用helm merics-server status查询日志

[root@master base]# kubectl get --raw "/apis/metrics.k8s.io/v1beta1/nodes"

{"kind":"NodeMetricsList","apiVersion":"metrics.k8s.io/v1beta1","metadata":{"selfLink":"/apis/metrics.k8s.io/v1beta1/nodes"},"items":[{"metadata":{"name":"10.1.6.100","selfLink":"/apis/metrics.k8s.io/v1beta1/nodes/10.1.6.100","creationTimestamp":"2020-09-16T09:27:58Z"},"timestamp":"2020-09-16T09:27:01Z","window":"30s","usage":{"cpu":"223236233n","memory":"4363840Ki"}},{"metadata":{"name":"10.1.6.101","selfLink":"/apis/metrics.k8s.io/v1beta1/nodes/10.1.6.101","creationTimestamp":"2020-09-16T09:27:58Z"},"timestamp":"2020-09-16T09:26:58Z","window":"30s","usage":{"cpu":"1084386738n","memory":"5706400Ki"}},{"metadata":{"name":"10.1.6.99","selfLink":"/apis/metrics.k8s.io/v1beta1/nodes/10.1.6.99","creationTimestamp":"2020-09-16T09:27:58Z"},"timestamp":"2020-09-16T09:27:03Z","window":"30s","usage":{"cpu":"740398897n","memory":"8287948Ki"}}]}

5、安装完后查看日志会有报错提示

E0916 09:08:22.238571 1 reststorage.go:160] unable to fetch pod metrics for pod kube-system/dashboard-metrics-scraper-c79c65bb7-xpqqb: no metrics known for pod

E0916 09:08:23.506206 1 manager.go:111] unable to fully collect metrics: [unable to fully scrape metrics from source kubelet_summary:10.1.6.101: unable to fetch metrics from Kubelet 10.1.6.101 (10.1.6.101): Get https://10.1.6.101:10250/stats/summary?only_cpu_and_memory=true: x509: certificate signed by unknown authority, unable to fully scrape metrics from source kubelet_summary:10.1.6.99: unable to fetch metrics from Kubelet 10.1.6.99 (10.1.6.99): Get https://10.1.6.99:10250/stats/summary?only_cpu_and_memory=true: x509: certificate signed by unknown authority, unable to fully scrape metrics from source kubelet_summary:10.1.6.100: unable to fetch metrics from Kubelet 10.1.6.100 (10.1.6.100): Get https://10.1.6.100:10250/stats/summary?only_cpu_and_memory=true: x509: certificate signed by unknow

6、这时需要修改deploy的一个值

kubectl -n kube-system edit deployments.apps metrics-server

spec:

containers:

- command:

- metrics-server

- --secure-port=8443

- --kubelet-insecure-tls

7、修改后就可以使用kubectl top node查看了

[root@master base]# kubectl top node

NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%

10.1.6.100 222m 1% 4264Mi 14%

10.1.6.101 1081m 9% 5579Mi 18%

10.1.6.99 703m 5% 8120Mi 27%

8、如果在pod重启或pod转移到其他节点后使用kubectl top node出现以下错误提示:

[root@master ~]# kubectl top nodes

Error from server (ServiceUnavailable): the server is currently unable to handle the request (get nodes.metrics.k8s.io)

则需要再修改deploy/metrics-server添加一行参数:

spec:

containers:

- command:

- metrics-server

- --secure-port=8443

- --kubelet-insecure-tls

- --kubelet-preferred-address-types=InternalIP

kubect安装 windows_k8s安装kubectl top命令相关推荐

  1. [提示]使用普通用户,通过sealos安装ks,默认还是要通过root用户才能正常使用kubectl等命令

    使用普通用户,通过sealos安装ks,默认还是要通过root用户才能正常使用kubectl等命令

  2. 在windows上的git bash中安装tree 和 linux tree命令使用

    在windows上的git bash中安装tree 和 linux tree命令使用 文章目录: 1 在windows上的git bash中安装tree 1.1 下载windows版本的tree 1. ...

  3. 容器编排技术 -- 安装和设置kubectl

    容器编排技术 -- 安装和设置kubectl 使用Kubernetes命令行工具kubectl在Kubernetes上部署和管理应用程序.使用kubectl,可以检查集群资源; 创建,删除和更新组件. ...

  4. JAVAWEB开发之——Linux命令实战、虚拟机和centos的安装以及联网、常用命令、vi编辑以及软件的安装、sftp的使用

    Linux简介 Linux是一种自由和开放源码的操作系统,存放着许多不同的Linux版本,但他们都使用了Linux内核.Linux可安装在各种计算机硬件中 比如.手机.平板电脑.路由器.台式计算机中. ...

  5. wramp php 命令,Linux环境的AMP安装 PHP安装

    Linux环境的AMP安装 PHP安装 3.PHP安装 1)还是下载源码包,如:php-5.1.1.tar.gz,下载地址:http://www.php.net 2)解压缩,>tar -zxvf ...

  6. linux添加磁盘后进入grub,从硬盘安装 Linux 和从 GRUB 命令行启动操作系统

    标题 +=================================================+ |  从硬盘安装 Linux 和从 GRUB 命令行启动操作系统  | +======== ...

  7. 安装完Hadoop之后,命令行输入hadoop或hdfs却找不到命令的解决方法

    安装完Hadoop之后,命令行输入hadoop或hdfs却找不到命令的解决方法 参考文章: (1)安装完Hadoop之后,命令行输入hadoop或hdfs却找不到命令的解决方法 (2)https:// ...

  8. createrepo命令安装_安装CDH6.3

    ​文档编写目的 Cloudera在2019年7月31日,对外宣布正式发布Cloudera Enterprise 6.3,相关介绍可以参考Fayson之前的文章<0682-Cloudera Ent ...

  9. 在 ubuntu 20.04 LTS 上安装 ROS2 执行 rosdep update 命令时出现的问题的解决办法

    在 ubuntu 20.04 LTS 上安装 ROS2 执行 rosdep update 命令时出现的问题的解决办法 1.sudo rosdep init 在执行 sudo rosdep init 命 ...

最新文章

  1. Java内存使用情况查看工具
  2. PHP序列化与反序列化(__sleep与__wakeup)
  3. 巧识滤波、稳压、比较、运放电路
  4. 徐波 博士 计算机,徐波教授:医工联合促进智能肿瘤学发展——探秘肿瘤精准治疗中的AI技术...
  5. 台式linux桌面远程链接华为云windows服务器桌面
  6. ashx是什么文件,什么时候使用ashx
  7. 为什么要关闭数据库连接,可以不关闭吗?
  8. 二叉树遍历之先序遍历算法(非递归、递归)入门详解
  9. 理解和解决requireJS的报错:MODULE NAME HAS NOT BEEN LOADED YET FOR CONTEXT
  10. Linux常用命令|徐奥雯编辑整理|XUAOWEN
  11. 2021最新爬取百度关键词时出现,百度安全验证,解决方法
  12. 利用python计算每个月有多少天和在两个日期中按月遍历
  13. c语言编译免疫算法亲和力,蚁群算法模拟系统设计及实现.doc
  14. javauniapp+SpringBoot即时通讯聊天软件源码
  15. [POJ2187]Beauty Contest(计算几何-旋转卡壳-最远点对)
  16. Loss.backward()
  17. Java使用阿里邮箱生成excle邮件附件发送
  18. VFIO Introduction
  19. mn数组计算java陆地和海洋01,2008年高三地理一轮复习精讲精练四—陆地和海洋
  20. 微信扫码支付功能(1)---通过谷歌二维码工具生成付款码

热门文章

  1. 【React Native】深入理解Native与RN通信原理
  2. 计算机管理映像路径,手把手教你解决win7系统任务管理器显示映像路径的恢复办法...
  3. Android ROM中加入第三方APP
  4. 电脑计算机怎么用键盘计算,电脑计算器还能这么用?
  5. KBP410-ASEMI开关电源整流器件KBP410
  6. 玩转96boards之(一)---高通410c板硬件
  7. 仿站高手是怎么练成的 分析仿站必备知识总结
  8. java面试英语自我介绍_【埃森哲java工程师面试】就是简单英文自我介绍。-看准网...
  9. AWS DynamoDB的简介与使用
  10. 手撸Spring系列4:IOC/DI 思想(实战篇)