In Kubernetes, application monitoring does not depend on a single monitoring solution. On new clusters, you can use two separate pipelines to collect monitoring statistics by default:
The resource metrics pipeline provides a limited set of metrics related to cluster components such as the HorizontalPodAutoscaler controller, as well as the kubectl top utility. These metrics > are collected by metrics-server and are exposed via the metrics.k8s.io API. metrics-server discovers all nodes on the cluster and queries each node’s Kubelet for CPU and memory usage. The
Kubelet fetches the data from cAdvisor. metrics-server is a lightweight short-term in-memory store.
https://kubernetes.io/docs/tasks/debug-application-cluster/resource-usage-monitoring/
大体意思是基础指标由metrics-serve
收集,通过 kubectl top
展示,并通过metrics.k8s.ioAPI 公开。metrics-server发现群集上的所有节点,并查询每个节点的Kubelet 以获取CPU和内存使用情况。`metrics-server`是一个轻量级的短期内存。
1.下载
$ wget https://github.com/kubernetes-incubator/metrics-server/archive/master.zip
2.unzip
$ unzip master.zip
3.进入目录
$ cd metrics-server-master/1.8+
4.修改yaml文件(镜像被墙)
$vim metrics-server-deployment.yaml
修改内容:image:registry.cn-beijing.aliyuncs.com/xingshulin/metrics-server-amd64:v0.2.1
5.创建
$kubectl create -f deploy/1.8+/
###效果
刚搭建完会没有数据,过几分钟就能收集到数据了
[root@VM\_0\_14\_centos 1.8+]# kubectl top node
error: metrics not available yet
[root@VM\_0\_14\_centos 1.8+]# kubectl top node
error: metrics not available yet
[root@VM\_0\_14\_centos 1.8+]# kubectl top node
NAME CPU(cores) CPU% MEMORY(bytes) MEMORY%
10.0.0.14 34m 3% 507Mi 69%
10.0.0.3 25m 2% 465Mi 63%
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。