@geekpi
https://linux.cn/article-15714-1.html
This commit is contained in:
Xingyu Wang 2023-04-12 10:12:17 +08:00
parent 776df9d0d3
commit d1f8b40c36

View File

@ -1,32 +1,34 @@
[#]: subject: "How to Install Kubernetes (K8s) Metrics Server Step by Step"
[#]: subject: "How to Install Kubernetes k8s Metrics Server Step by Step"
[#]: via: "https://www.linuxtechi.com/how-to-install-kubernetes-metrics-server/"
[#]: author: "Pradeep Kumar https://www.linuxtechi.com/author/pradeep/"
[#]: collector: "lkxed"
[#]: translator: "geekpi"
[#]: reviewer: " "
[#]: publisher: " "
[#]: url: " "
[#]: reviewer: "wxy"
[#]: publisher: "wxy"
[#]: url: "https://linux.cn/article-15714-1.html"
如何逐步安装 Kubernetes (K8s) 指标服务器
如何逐步安装 Kubernetesk8s指标服务器
======
在这篇文章中,我们将逐步介绍如何安装 Kubernetes 指标服务器。
![][0]
Kubernetes(k8s) 指标服务器是一个组件,用于收集和聚合来自 Kubernetes 集群中各种来源(包括节点和 Pod的指标数据。此数据可用于监控和优化资源利用率、识别潜在问题并提高 Kubernetes 集群的整体性能
> 在这篇文章中,我们将逐步介绍如何安装 Kubernetes 指标服务器
指标服务器收集资源利用率数据,例如集群中节点和 Pod 的 CPU 和内存使用情况。它提供了一个 API 端点,可用于查询此数据并检索集群中特定资源的指标。
Kubernetesk8s指标服务器是一个组件用于收集和聚合来自 Kubernetes 集群中各种来源(包括节点和 <ruby>容器荚<rt>Pod</rt></ruby>)的指标数据。此数据可用于监控和优化资源利用率、识别潜在问题并提高 Kubernetes 集群的整体性能。
指标服务器收集资源利用率数据,例如集群中节点和容器荚的 CPU 和内存使用情况。它提供了一个 API 端点,可用于查询此数据并检索集群中特定资源的指标。
##### 先决条件
- 启动并运行 Kubernetes 集群v1.21 或更高版本)。
- kubectl 命令行工具已安装并配置为与你的 Kubernetes 集群交互。
- `kubectl` 命令行工具已安装并配置为与你的 Kubernetes 集群交互。
- 创建和修改 Kubernetes 对象的能力。
事不宜迟,让我们深入了解安装步骤。
### 步骤 1) 下载指标服务器清单
### 步骤 1 下载指标服务器清单
第一步是从 Kubernetes GitHub 仓库下载最新的指标服务器清单文件。使用下面的 curl 命令下载 yaml 文件:
第一步是从 Kubernetes GitHub 仓库下载最新的指标服务器清单文件。使用下面的 `curl` 命令下载 yaml 文件:
```
# curl -LO https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
@ -40,21 +42,21 @@ Kubernetes(k8s) 指标服务器是一个组件,用于收集和聚合来自 Kub
# curl https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/high-availability-1.21+.yaml
```
### 步骤 2修改指标服务器 Yaml 文件
### 步骤 2 修改指标服务器 Yaml 文件
接下来,你需要修改 Metrics Server yaml 文件以设置一些配置选项:
接下来,你需要修改指标服务器的 yaml 文件以设置一些配置选项:
```
# vi components.yaml
```
找到 container 下的 args 部分,添加以下行:
找到 `container` 下的 `args` 部分,添加以下行:
```
- --kubelet-insecure-tls
```
在 spec 下,添加以下参数:
`spec` 下,添加以下参数:
```
hostNetwork: true
@ -64,9 +66,9 @@ hostNetwork: true
保存并关闭文件。
### 步骤 3部署指标服务器
### 步骤 3 部署指标服务器
现在,我们准备好部署指标服务器,运行以下 kubectl 命令:
现在,我们准备好部署指标服务器,运行以下 `kubectl` 命令:
```
# kubectl apply -f components.yaml
@ -74,9 +76,9 @@ hostNetwork: true
![][3]
### 步骤 4验证指标服务器部署
### 步骤 4 验证指标服务器部署
部署指标服务器后,通过检查在 kube-system 命名空间中运行的 pod 状态来验证它的状态:
部署指标服务器后,通过检查在 `kube-system` 命名空间中运行的容器荚状态来验证它的状态:
```
# kubectl get pods -n kube-system
@ -84,11 +86,11 @@ hostNetwork: true
![][4]
上面的输出确认指标服务器 pod 已启动并正在运行。
上面的输出确认指标服务器容器荚已启动并正在运行。
### 步骤 5测试指标服务器安装
### 步骤 5 测试指标服务器安装
最后,你可以通过运行以下 kubectl 命令来测试指标服务器:
最后,你可以通过运行以下 `kubectl` 命令来测试指标服务器:
```
# kubectl top nodes
@ -98,7 +100,7 @@ hostNetwork: true
![][5]
要查看当前命名空间或特定命名空间的 pod 资源利用率,请运行:
要查看当前命名空间或特定命名空间的容器荚资源利用率,请运行:
```
# kubectl top pod
@ -109,6 +111,8 @@ hostNetwork: true
这就是这篇文章的全部内容,我希望你能从中找到有用的信息。请在下面的评论部分发表你的反馈和疑问。
*题图MJ: Kubernetes container paper art light blue background ultra-detailed topview*
--------------------------------------------------------------------------------
via: https://www.linuxtechi.com/how-to-install-kubernetes-metrics-server/
@ -116,7 +120,7 @@ via: https://www.linuxtechi.com/how-to-install-kubernetes-metrics-server/
作者:[Pradeep Kumar][a]
选题:[lkxed][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
@ -127,4 +131,5 @@ via: https://www.linuxtechi.com/how-to-install-kubernetes-metrics-server/
[3]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Deploy-Metrics-Server-Kubectl-Command.png
[4]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Metrics-Server-Pods-Status-Kube-System.png
[5]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Kubectl-top-node-command-Output.png?ezimgfmt=ng:webp/ngcb22
[6]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Kubectl-top-pod-command-output.png
[6]: https://www.linuxtechi.com/wp-content/uploads/2023/03/Kubectl-top-pod-command-output.png
[0]: https://img.linux.net.cn/data/attachment/album/202304/12/100919k6p6yyweu6nv6nkh.jpg